博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
gdb调试libtool封装的可执行文件
阅读量:6853 次
发布时间:2019-06-26

本文共 2716 字,大约阅读时间需要 9 分钟。

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 ):

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$

转载于:https://www.cnblogs.com/ericsun/p/3168842.html

你可能感兴趣的文章
hadoop1.x作业提交过程分析(源码分析第二篇)
查看>>
默认安装vsftpd后
查看>>
《Redis设计与实现》读书笔记
查看>>
waiting for changelog lock.
查看>>
小白学爬虫-批量部署Splash负载集群
查看>>
你离BAT之间,只差这一套Java面试题
查看>>
laravel package 推荐,数据备份
查看>>
Synchronized锁在Spring事务管理下,为啥还线程不安全?
查看>>
环境变量PATH cp命令 mv命令 文档查看cat/more/less/head/tail
查看>>
阿里云亮相2019联通合作伙伴大会,边缘计算等3款云产品助力5G时代产业数字化转型...
查看>>
dubbo源码分析-服务端发布流程-笔记
查看>>
阿里云发布Apsara SA系列混合云存储阵列
查看>>
GoJS教程:链接模版
查看>>
QListWidget方式显示缩略图
查看>>
金三银四:蚂蚁金服JAVA后端面试题及答案之二面
查看>>
Ubuntu 外网不通解决方案
查看>>
OSChina 周六乱弹 —— 历史总是惊人的相似
查看>>
MySQL 大小写
查看>>
Lync 2013部署图片赏析-证书服务安装配置
查看>>
HTML5 本地缓存 (web存储)
查看>>