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$

最新文章

  1. [转] 从知名外企到创业公司做CTO是一种怎样的体验?
  2. HashMap实现缓存(二)
  3. DOJO-dojox.grid.EnhancedGrid(带刷新函数,分页工具栏,复选框,行号等功能)
  4. R提高篇(一): 输入输出
  5. 黄聪:PHP5.6+7代码性能加速-开启Zend OPcache-优化CPU
  6. 怎样在VS2013/MFC中使用TeeChart绘图控件
  7. js作用域的一个小例子
  8. 01-08-01【Nhibernate (版本3.3.1.4000) 出入江湖】NHibernate中的三种状态
  9. Apache James搭建内网邮件服务器
  10. docker 错误
  11. Android 自定义View修炼-Android实现圆形、圆角和椭圆自定义图片View(使用BitmapShader图形渲染方法)
  12. .NET基础拾遗(1)类型语法基础和内存管理基础2
  13. struts2集成fckeditor(来自大型门户网站是这样练成的一书)
  14. Android组件生命周期(二)
  15. PPT要你好看---读书笔记
  16. mock server 前后端分离小结(转)
  17. chainsql异常记录
  18. 差分线Layout的两个误区
  19. Laravel 5.2问题-----postman进api的post请求,为什么出现Forbidden?
  20. mkvirtualenv command not found解决

热门文章

  1. zabbix debug and vulnerability https://www.zabbix.com/documentation/3.0/manual/concepts/sender
  2. Django框架【基础篇】
  3. django之中间件、缓存、信号、admin内置后台
  4. sql小知识
  5. Yarn之ResourceManager详细分析
  6. 使用jQuery包装节点
  7. 凌华AMP-204C卡的CNC功能 即Feeder工具的使用。
  8. Android初体验之Monkey和MonkeyRunner
  9. node必知必会之node简介
  10. mysql索引之哈希索引