gdb调试libtool封装的可执行文件
http://www.gnu.org/software/libtool/manual/html_node/Debugging-executables.html
3.4 Debugging executables
Ifhellwas a complicated program, you would certainly want to test and debug it before installing it on your system. In the above section, you saw how the libtool wrapper script makes it possible to run the program directly, but unfortunately, this mechanism interferes with the debugger:
burger$ gdb hell
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is no warranty for GDB; type "show warranty" for details.
GDB 4.16 (i386-unknown-netbsd), (C) 1996 Free Software Foundation, Inc. "hell": not in executable format: File format not recognized (gdb) quit
burger$
Sad. It doesn't work because GDB doesn't know where the executable lives. So, let's try again, by invoking GDB directly on the executable:
burger$ gdb .libs/hell
GNU gdb 5.3 (i386-unknown-netbsd)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License,
and you are welcome to change it and/or distribute copies of it
under certain conditions. Type "show copying" to see the conditions.
There is no warranty for GDB. Type "show warranty" for details.
(gdb) break main
Breakpoint 1 at 0x8048547: file main.c, line 29.
(gdb) run
Starting program: /home/src/libtool/demo/.libs/hell
/home/src/libtool/demo/.libs/hell: can't load library 'libhello.so.0' Program exited with code 020.
(gdb) quit
burger$
Argh. Now GDB complains because it cannot find the shared library thathellis linked against. So, we must use libtool in order to properly set the library path and run the debugger. Fortunately, we can forget all about the.libsdirectory, and just run it on the executable wrapper (see Execute mode):
burger$ libtool --mode=execute gdb hell
GNU gdb 5.3 (i386-unknown-netbsd)
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License,
and you are welcome to change it and/or distribute copies of it
under certain conditions. Type "show copying" to see the conditions.
There is no warranty for GDB. Type "show warranty" for details.
(gdb) break main
Breakpoint 1 at 0x8048547: file main.c, line 29.
(gdb) run
Starting program: /home/src/libtool/demo/.libs/hell Breakpoint 1, main (argc=1, argv=0xbffffc40) at main.c:29
29 printf ("Welcome to GNU Hell!\n");
(gdb) quit
The program is running. Quit anyway (and kill it)? (y or n) y
burger$
gdb调试libtool封装的可执行文件的更多相关文章
- 使用GDB调试将符号表与程序分离后的可执行文件
环境: Centos7.3.GCC4.8.5 适用场景: 由于调试信息比较大,通常将程序分离为可执行程序和符号信息文件,只对外发布可执行程序,需要调试时再将符号信息文件附加. 一.创建可执行程序: u ...
- gdb调试原理及qemu中的gdbserver
(一)gdb调试原理 此部分转自:https://blog.csdn.net/u012658346/article/details/51159971 https://www.cnblogs.c ...
- Linux——【转】gcc编译与gdb调试简要步骤
原文:gcc编译与gdb调试简要步骤 一.Linux程序gcc编译步骤: Gcc编译过程主要的4个阶段: l 预处理阶段,完成宏定义和include文件展开等工作:(.i) l 根据编译参数进行不同程 ...
- linux基础2——gdb调试器
gdb调试器使用的一般步骤(不断更新完善): 1.编译过程中要用-g参数来添加调试符号——gcc test.c -g: 2.gdb启动可执行文件——gdb a.out: 3.出现gdb符号表示启动成功 ...
- Linux下GDB调试
GDB 是一个强大的命令行调试工具.大家知道命令行的强大就是在于,其可以形成执行 序列,形成脚本.UNIX 下的软件全是命令行的,这给程序开发提供了极大的便利,命令行 软件的优势在于, 他们可以非常容 ...
- gcc编译与gdb调试简要步骤
http://blog.chinaunix.net/uid-24103300-id-108248.html 一.Linux程序gcc编译步骤: Gcc编译过程主要的4个阶段: l 预处理阶段,完成宏定 ...
- gdb调试常用命令
gdb 调试常用命令 gcc -g mian.c -o main.out -o (定制生成的可执行文件的名称,缺省时为a.out) -g 使gdb可调试,在编译的时候,产生调试信息 gdb main. ...
- 20145219 gdb调试汇编堆栈分析
20145219 gdb调试汇编堆栈分析 代码gdbdemo.c int g(int x) { return x+19; } int f(int x) { return g(x); } int mai ...
- gdb调试汇编堆栈分析
代码(src/05/gdb.c) int g(int x) { return x + 4; } int f(int x) { return g(x); } int main(void) { retur ...
随机推荐
- Token Based Authentication -- Implementation Demonstration
https://www.w3.org/2001/sw/Europe/events/foaf-galway/papers/fp/token_based_authentication/
- saml,sso
saml,sso centos version get:// cat /etc/redhat-release
- Faster R-CNN论文详解 - CSDN博客
废话不多说,上车吧,少年 paper链接:Faster R-CNN: Towards Real-Time Object Detection with Region Proposal Networks ...
- 监听checkbox事件
<!DOCTYPE html> <html> <head> <title></title> </head> <script ...
- api收录
ip地址查询api http://ip.taobao.com/service/getIpInfo.php?ip= 如: http://ip.taobao.com/service/getIpInfo.p ...
- sql server 碎片整理——DBCC SHOWCONTIG
转自: 1.http://blog.sina.com.cn/s/blog_6d2675450101ks6i.html 2.http://www.cnblogs.com/CareySon/archive ...
- log4j2介绍及配置
一.log4j2概述 在日常的开发,测试和生产环境中,日志记录了应用,服务运行过程中的关键信息,以及出现异常时的堆栈,这些信息常常作为查询,定位,解决问题的关键,因此在任何系统中,对日志的使用得当,将 ...
- docker——核心实现技术
作为一种容器虚拟化技术,Docker深度应用了操作系统的多项底层支持技术. 早期版本的Docker是基于已经成熟的Linux Container(LXC)技术实现的.自从0.9版本起,Docker逐渐 ...
- 4.6 Routing -- Rendering A Tempalte
1. route handler一个重要的任务就是渲染合适的模板到屏幕. 2. 默认的,一个route handler将会呈现模板到最近的父模板. app/router.js Router.map(f ...
- C++ string 类
标准c++中string类函数介绍 注意不是CString之所以抛弃char*的字符串而选用C++标准程序库中的string类,是因为他和前者比较起来,不必 担心内存是否足够.字符串长度等等,而且作为 ...