注意这行: EIP is at list_del+0xa/0x61 这告诉我们,list_del函数有0x61这么大,而Oops发生在0xa处。 那么我们先看一下list_del从哪里开始:
# grep list_del /boot/System.map-2.6.24-rc3-module c10e5234 T plist_del c10e53cc T list_del c120feb6 T klist_del c12d6d34 r __ksymtab_list_del c12dadfc r __ksymtab_klist_del c12e1abd r __kstrtab_list_del c12e9d03 r __kstrtab_klist_del
于是我们知道,发生Oops时的EIP值是:
c10e53cc + 0xa == c10e53d6
然后用gdb查看:
# gdb /home/arc/build/linux-2.6/vmlinux (gdb) b *0xc10e53d6 Breakpoint 1 at 0xc10e53d6: file /usr/src/linux-2.6.24-rc3/lib/list_debug.c, line 64.
看,gdb直接就告诉你在哪个文件、哪一行了。
gdb中还可以这样:
# gdb Sources/linux-2.6.24/vmlinux (gdb) l *do_fork+0x1f 0xc102b7ac is in do_fork (kernel/fork.c:1385). 1380 1381 static int fork_traceflag(unsigned clone_flags) 1382 { 1383 if (clone_flags & CLONE_UNTRACED) 1384 return 0; 1385 else if (clone_flags & CLONE_VFORK) { 1386 if (current->ptrace & PT_TRACE_VFORK) 1387 return PTRACE_EVENT_VFORK; 1388 } else if ((clone_flags & CSIGNAL) != SIGCHLD) { 1389 if (current->ptrace & PT_TRACE_CLONE) (gdb)
也可以直接知道line number。
或者:
(gdb) l *(0xffffffff8023eaf0 + 0xff) /* 出错函数的地址加上偏移 */
[arc@dhcp-cbjs05-218-251 ~]$ gdb hello GNU gdb Fedora (6.8-1.fc9) Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <[url][/url]> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-redhat-linux-gnu"... (no debugging symbols found) (gdb) r Starting program: /home/arc/hello 0x80484e0
Program received signal SIGSEGV, Segmentation fault.