如何在linux中找到不同的内存段起始及其大小

Tha*_*raj -1 c linux debugging gdb

我是linux的新手.我想知道不同段的起始地址和大小(如堆栈,堆,数据等)及其当前用法.

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

提前致谢.

Fre*_*ihl 5

从查看proc(5)文件系统开始.man是你的朋友.

/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.
Run Code Online (Sandbox Code Playgroud)

看看info proc mappings,除了没有/ proc时(例如在正面调试期间)它不起作用.