核心转储中的部分数量多于mmaped

时间:2012-10-02 05:59:25

标签: linux memory core mmap

我正在尝试调试内核模块。我有一段代码来获取进程中的地图数量:

    static int tmp_func(void){
      int count = 0;
      struct mm_struct  *mm = current->mm;
      struct vm_area_struct *map;
      down_read(&mm->mmap_sem);
      /* 1. just counts maps ... */
      for (map = mm->mmap; map ; map = map->vm_next) {
         count ++;
      }
      up_read(&mm->mmap_sem);
      printk("tmp_func,count: %d\n",count);
      return count;
    }

它返回28.当我检查核心转储时,有32个负载:

    (gdb)maintenance info sections
     ....
     Core file:
     file type elf64-x86-64.
     0x00000000->0x00000344 at 0x00000778: note0 READONLY HAS_CONTENTS
     0x00000000->0x000000d8 at 0x000007fc: .reg/22787 HAS_CONTENTS
     0x00000000->0x000000d8 at 0x000007fc: .reg HAS_CONTENTS
     0x00000000->0x00000130 at 0x0000098c: .auxv HAS_CONTENTS
     0x00400000->0x00400000 at 0x00001000: load1 ALLOC READONLY CODE
     0x00600000->0x00601000 at 0x00001000: load2 ALLOC LOAD HAS_CONTENTS
     0x00601000->0x00622000 at 0x00002000: load3 ALLOC LOAD HAS_CONTENTS
     0x390ee00000->0x390ee00000 at 0x00023000: load4 ALLOC READONLY CODE
     0x390f01c000->0x390f01d000 at 0x00023000: load5 ALLOC LOAD READONLY HAS_CONTENTS
     0x390f01d000->0x390f01e000 at 0x00024000: load6 ALLOC LOAD HAS_CONTENTS
     0x390f200000->0x390f200000 at 0x00025000: load7 ALLOC READONLY CODE
     0x390f34e000->0x390f34e000 at 0x00025000: load8 ALLOC READONLY
     0x390f54e000->0x390f552000 at 0x00025000: load9 ALLOC LOAD READONLY HAS_CONTENTS
     0x390f552000->0x390f553000 at 0x00029000: load10 ALLOC LOAD HAS_CONTENTS
     0x390f553000->0x390f558000 at 0x0002a000: load11 ALLOC LOAD HAS_CONTENTS
     0x390f600000->0x390f600000 at 0x0002f000: load12 ALLOC READONLY CODE
     0x390f602000->0x390f602000 at 0x0002f000: load13 ALLOC READONLY
     0x390f802000->0x390f803000 at 0x0002f000: load14 ALLOC LOAD READONLY HAS_CONTENTS
     0x390f803000->0x390f804000 at 0x00030000: load15 ALLOC LOAD HAS_CONTENTS
     0x390fa00000->0x390fa00000 at 0x00031000: load16 ALLOC READONLY CODE
     0x390fa16000->0x390fa16000 at 0x00031000: load17 ALLOC READONLY
     0x390fc15000->0x390fc16000 at 0x00031000: load18 ALLOC LOAD READONLY HAS_CONTENTS
     0x390fc16000->0x390fc17000 at 0x00032000: load19 ALLOC LOAD HAS_CONTENTS
     0x390fc17000->0x390fc1b000 at 0x00033000: load20 ALLOC LOAD HAS_CONTENTS
     0x3912200000->0x3912200000 at 0x00037000: load21 ALLOC READONLY CODE
     0x391220d000->0x391220d000 at 0x00037000: load22 ALLOC READONLY
     0x391240d000->0x391240e000 at 0x00037000: load23 ALLOC LOAD HAS_CONTENTS
     0x2b1df1bef000->0x2b1df1bf1000 at 0x00038000: load24 ALLOC LOAD HAS_CONTENTS
     0x2b1df1bf1000->0x2b1df1bf1000 at 0x0003a000: load25 ALLOC READONLY CODE
     0x2b1df1bfa000->0x2b1df1bfa000 at 0x0003a000: load26 ALLOC READONLY
     0x2b1df1dfa000->0x2b1df1dfb000 at 0x0003a000: load27 ALLOC LOAD HAS_CONTENTS
     0x2b1df1dfb000->0x2b1df1dfd000 at 0x0003b000: load28 ALLOC LOAD HAS_CONTENTS
     0x2b1df1e0f000->0x2b1df1e12000 at 0x0003d000: load29 ALLOC LOAD HAS_CONTENTS
     0x7fff99a35000->0x7fff99a4a000 at 0x00040000: load30 ALLOC LOAD HAS_CONTENTS
     0x7fff99b5e000->0x7fff99b5f000 at 0x00055000: load31 ALLOC LOAD READONLY CODE HAS_CONTENTS
     0xffffffffff600000->0xffffffffff600000 at 0x00056000: load32 ALLOC READONLY CODE

我查了一下,发现我的代码中没有计算出负载3,21,22,23。

我得到了所有部分的全部内容。这里:

    load3: has libgcc_s.so.1
    load21 and load22 were not there
    load23: nothing meaningful (seems to be a Hash Section)

我想知道可能是什么原因。

info:x86_64,centos 5.7,2.6.32,GCC 4.1.2。

[编辑:我的应用程序是一个带有printf和sleep的for循环]

0 个答案:

没有答案