Chinaunix首页 | 论坛 | 博客
  • 博客访问: 187045
  • 博文数量: 50
  • 博客积分: 1053
  • 博客等级: 少尉
  • 技术积分: 577
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-05 22:55
文章分类

全部博文(50)

文章存档

2016年(2)

2015年(1)

2014年(6)

2012年(11)

2011年(22)

2010年(5)

2009年(3)

我的朋友

分类: LINUX

2011-03-29 10:18:05

Debugging Shared Libraries in gdb and ddd
I looked everywhere for a straight answer on this, and couldn't find one. So once i figured it out I figured I'd help anyone else out who runs into the same problems. This is just based on experience, not on research.

So if something's wrong here LMK.

I'm using:
ddd 3.3.7 (i386-suse-linux-gnu) gdb 5.3.92 gcc version 3.3.1 (SuSE Linux)
ddd seems to sort of half supports delayed breakpoints.

If you debug your binary (with shared libraries loaded) once, set the breakpoints needed, and then kill it ddd will save those breakpoints, and try to set them in the next debugging session every time a shared library is loaded.



The problem is in many cases gdb will give a dumb message after loading the shared library with breakpoints in question, effectively bringing debugging to a halt:


error in loading shared libraries: libsome_file.so.1: failed to map segment from shared object: Cannot allocate memory
To get around this problem, preload the the library using the LD_PRELOAD environment variable.

 

Use the following command at the ddd or gdb command line:
set environment LD_PRELOAD /usr/lib/libsome_file.so.1

阅读(1437) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~