1

カーネルモジュールをデバッグしようとしています。プロセス内のマップの数を取得するためのコードがあります。

    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)

何が原因なのか気になります。

情報:x86_64、centos 5.7、2.6.32、GCC4.1.2。

[編集:ここでの私のアプリケーションは、printfとsleepを使用したforループです]

4

0 に答える 0