【发布时间】:2014-04-07 11:03:01
【问题描述】:
当我们共享自定义构建的内核时,通常不提供调试信息。
类似于sudo apt-get install linux-image-$(uname -r)-dbgsym,我想为自定义构建的内核创建单独的调试信息文件。
Here 和here 他们进行了一般性的解释。我请求分享为整个 linux 内核创建单独的调试信息文件的知识。
示例程序
$ gcc -g calc.c
$ ls -l
total 16
-rwxrwxr-x 1 jeyaram jeyaram 8424 Apr 8 09:44 a.out
-rw-rw-r-- 1 jeyaram jeyaram 246 Apr 8 09:32 calc.c
$ objcopy --only-keep-debug a.out a.debug
$ gcc calc.c -------------> compiling without debug info (skipped 'strip')
$ ls -l
total 20
-rwxrwxr-x 1 jeyaram jeyaram 4736 Apr 8 09:45 a.debug
-rwxrwxr-x 1 jeyaram jeyaram 7200 Apr 8 09:52 a.out
-rw-rw-r-- 1 jeyaram jeyaram 246 Apr 8 09:32 calc.c
$ objcopy --add-gnu-debuglink=a.debug a.out
$ gdb a.out
GNU gdb (Ubuntu/Linaro 7.4-2012.02-0ubuntu2) 7.4-2012.02
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
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 "i686-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/jeyaram/JJJ/debug_info_analysis/sample_c_test/a.out...Reading symbols from /home/jeyaram/JJJ/debug_info_analysis/sample_c_test/a.debug...done.
done.
但是在尝试使用 vmlinux 时
$ objcopy --only-keep-debug vmlinux vmlinux.debug
objcopy: Unable to recognise the format of the input file `vmlinux'
缺少什么???
【问题讨论】:
-
看起来很简单。使用“Kernel hacking”
.config构建内核以创建带有所有调试的映像。运行objcopy --only-keep-debug vmlinux vmlinux.debug、strip vmlinux,并可选择添加链接objcopy --add-gnu-debuglink=vmlinux.debug vmlinux。 vmlinux 二进制文件与其他 ELF 文件没有什么不同。如果没有make/config 选项来创建它,我会感到惊讶;但这些是手动步骤。
标签: linux linux-kernel arm debug-information