Why are there no debug symbols in my vmlinux when using gdb with /proc/kcore?

后端 未结 5 2041
长发绾君心
长发绾君心 2021-01-11 15:46

I\'ve configure all CONFIG_DEBUG_ related options to y,but when I try to debug the kernel,it says no debug symbols found:

gdb /usr/         


        
相关标签:
5条回答
  • 2021-01-11 16:22

    I might be wrong, but I thought you would have to install the debuginfo package for your kernel to get symbols

    0 讨论(0)
  • 2021-01-11 16:30

    Add -g to the CFLAGS variable in the kernel Makefile

    0 讨论(0)
  • 2021-01-11 16:31

    It's also possible when you package your vmlinuz image, the debug symbols were stripped (when using make-kpkg to build deb package for linux kernel). So you have to use the built vmlinux file under your linux source tree to have those debug symbols.

    0 讨论(0)
  • 2021-01-11 16:35

    make menuconfig->kernel hacking->[]Kernel debugging->[]Compile the kernel with debug info(CONFIG_DEBUG_INFO)

    0 讨论(0)
  • 2021-01-11 16:37

    Here is my best guess so far: I don't know, and it doesn't matter.

    I don't know why GDB is printing the message "(no debugging symbols found)". I've actually seen this when building my own kernels. I configure a kernel to use debug symbols, but GDB still prints this message when it looks at the kernel image. I never bothered to look into it, because my image can still be debugged fine. Despite the message, GDB can still disassemble functions, add breakpoints, look up symbols, and single-step through functions. I never noticed a lack of debugging functionality. I'm guessing that the same thing is happening to you.

    Edit: Based on the your comments to the question, it looks like you were searching for the wrong symbol with your debugger. System call handlers start with a prefix of sys_, but you can't tell from looking at the code. The macro SYSCALL_DEFINE4(ptrace, ...) just ends up declaring the function as asmlinkage long sys_ptrace(...), although it does some other crazy stuff if you have ftrace enabled.

    0 讨论(0)
提交回复
热议问题