gpt4 book ai didi

c - 如何在 Linux 中找到不同的内存段起始位置及其大小

转载 作者:行者123 更新时间:2023-12-05 08:35:14 25 4
gpt4 key购买 nike

我是 Linux 新手。我想知道不同段(如堆栈、堆、数据等)的起始地址和大小及其当前使用情况。

我想知道如何在运行进程和核心转储中找到。

提前致谢。

最佳答案

首先查看 proc(5) 文件系统。 man 是你的 friend 。

/proc/[number]/maps 包含当前映射的内存区域及其访问权限的文件

在gdb中,你可以使用

$ gdb -q
(gdb) help info proc
Show /proc process information about any running process.
Specify any process id, or use the program being debugged by default.
Specify any of the following keywords for detailed info:
mappings -- list of mapped memory regions.
stat -- list a bunch of random process info.
status -- list a different bunch of random process info.
all -- list all available /proc info.

查看 info proc mappings,除非它在没有/proc 时不起作用(例如在事后调试期间)。

关于c - 如何在 Linux 中找到不同的内存段起始位置及其大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6622237/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com