Nan*_*iao 5 linux gdb debug-symbols archlinux
我的操作系统是Arch Linux,程序test.c很简单:
# cat test.c
#include <stdio.h>
int main(void) {
printf("Hello world!\n");
}
Run Code Online (Sandbox Code Playgroud)
不带选项编译-g,使用file命令查看可执行文件信息:
# gcc test.c
# file a.out
a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=c7a538046222b5209d2daafbfc246de341a652d9, not stripped, with debug_info
Run Code Online (Sandbox Code Playgroud)
该file命令输出“ not stripped, with debug_info”,但我在编译期间不使用-g选项。用于gdb调试a.out:
# gdb a.out
GNU gdb (GDB) 7.12.1
Copyright (C) 2017 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 "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.out...(no debugging symbols found)...done.
(gdb)
Run Code Online (Sandbox Code Playgroud)
我还可以看到gdb提示“ Reading symbols from a.out...(no debugging symbols found)...done.”。
为什么file命令在编译时报告not stripped, with debug_info没有“ ”选项的可执行文件的“ -g”?
为什么 file 命令在编译期间报告没有“-g”选项的可执行文件的“not stripped, with debug_info”?
您的程序链接到部分libc_nonshared.a(例如 c 运行时启动ctr0.o),其中可能包含一些调试信息。
您可以查看可用的调试信息并猜测它来自哪里:
readelf -wl ./a.out
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4128 次 |
| 最近记录: |