2013年8月23日 星期五

紀錄一下/proc/pid/maps的使用

在跑起來的一支程式,可用cat /proc/pid/maps 來看他的memory layout
(似乎只看的到user space的)

以下是這段code看到的資訊:



  • address - The starting and ending address of the region in the process's address space
  • permissions - rwx就不用講了,p代表的是private(not shared),意義我也不懂@@
  • offset - Where the memory area begins in the file that it is mapped to. An offset of 0
    means that the beginning of the memory area corresponds to the beginning of
    the file.
  • device - If the region was mapped from a file, this is the major and minor device number (in hex) where the file lives.
  • inode - If the region was mapped from a file, this is the file number.
  • pathname - If the region was mapped from a file, this is the name of the file. This field is blank for anonymous mapped regions
reference : http://stackoverflow.com/questions/1401359/understanding-linux-proc-id-maps

其中這三個
應該是由上而下依序代表text(code) section, data section, BSS(uninitialization data) section

64bit的server上跑的@@
改天找個32bit machine跑對我來說比較容易

0 意見:

張貼留言