본문 바로가기

Core BSP 분석/리눅스 커널 핵심 분석

Crash 명령어 스택 심볼 보기

아래와 같이 커널 패닉 로그가 나왔을 때,
[   35.106647 01-05 13:30:50.343] [<c01e332c>] (ext4_free_inode+0x288/0x574) from [<c01ec5e0>] (ext4_evict_inode+0x2f0/0x4c0)
[   35.117770 01-05 13:30:50.354] [<c01ec5e0>] (ext4_evict_inode+0x2f0/0x4c0) from [<c0170da4>] (evict+0x9c/0x184)
[   34.943888 01-05 13:30:50.180] Process system_server (pid: 928, stack limit = 0xe0e9e2f0)
[   34.952098 01-05 13:30:50.188] Stack: (0xe0e9fe38 to 0xe0ea0000)
....
[   35.127937 01-05 13:30:50.364] [<c0170da4>] (evict+0x9c/0x184) from [<c0171328>] (iput+0x104/0x1ec)
[   35.137061 01-05 13:30:50.373] [<c0171328>] (iput+0x104/0x1ec) from [<c01658ac>] (do_unlinkat+0x11c/0x160)
[   35.146793 01-05 13:30:50.383] [<c01658ac>] (do_unlinkat+0x11c/0x160) from [<c016731c>] (sys_unlink+0x20/0x24)
[   35.156873 01-05 13:30:50.393] [<c016731c>] (sys_unlink+0x20/0x24) from [<c000f040>] (ret_fast_syscall+0x0/0x30)

아래와 같이 크래시 명령어를 쓰면, 프로세스가 스택에서 어느 함수까지 진입을 했는 지 정확히 알 수 있다.
마치 CCTV로 프로세스가 뭔 짓을 했는 지 알 수 있는 것이다.
rd -S [주소] [보고 싶은 주소 범위]

crash> rd -S 0xe0e9fe38 200
e0e9fe38:  e0e9e000 00000000 e0e9fe9c e0e9fe50
e0e9fe48:  ext4_mark_inode_dirty+0x8c 00000000 [size-1024] 00000040
e0e9fe58:  c21ae420 00001f70 [size-1024] 00040d7a
e0e9fe68:  00000a00 [buffer_head] ext4_truncate+0x10c [ext4_inode_cache]
e0e9fe78:  [jbd2_journal_handle] ext4_sops ext4_sops sys_call_table
e0e9fe88:  e0e9e000 00000000 e0e9fecc e0e9fea0
e0e9fe98:  ext4_evict_inode+0x2f0 ext4_free_inode+0xc [dentry] _raw_spin_lock+0x18
e0e9fea8:  [ext4_inode_cache] [ext4_inode_cache] [ext4_inode_cache] ext4_sops
e0e9feb8:  ext4_sops sys_call_table e0e9feec e0e9fed0
e0e9fec8:  evict+0x9c ext4_evict_inode+0xc 00000000 [ext4_inode_cache]
e0e9fed8:  [ext4_inode_cache] [size-1024] e0e9ff0c e0e9fef0
e0e9fee8:  iput+0x104 evict+0xc [dentry] [ext4_inode_cache]
e0e9fef8:  00000000 0000000a e0e9ff94 e0e9ff10
e0e9ff08:  do_unlinkat+0x11c iput+0xc [mnt_cache] [names_cache]
e0e9ff18:  [mnt_cache] [dentry] b63192cd 00000014
e0e9ff28:  [names_cache] 00000000 [dentry] [ext4_inode_cache]
e0e9ff38:  00000000 00000002 00000000 00000000
e0e9ff48:  10300002 __vet_atags+0x2c 00000001 000003e8
e0e9ff58:  000003e8 00000000 00000129 00000000
e0e9ff68:  52c8def1 17c841c3 52c8def1 1e848003
e0e9ff78:  52c8def1 60832fa0 4161d7a0 00000000
e0e9ff88:  e0e9ffa4 e0e9ff98 sys_unlink+0x20 do_unlinkat+0xc
e0e9ff98:  00000000 e0e9ffa8 ret_fast_syscall sys_unlink+0xc