gdb调式跟踪libstdc++代码

软件和网站开发以及相关技术探讨
回复
ubuntufree
帖子: 7
注册时间: 2014-04-04 23:09
系统: Windows+ubuntu
送出感谢: 0
接收感谢: 0

gdb调式跟踪libstdc++代码

#1

帖子 ubuntufree » 2014-09-15 14:47

如题,想用gdb调试C++程序,但发现gdb跟踪不了C++库文件里的函数(类)。求教如何用gdb调试C++的库文件?即可以在运行gdb时,用CTRL+ALT+A看到C++库文件里的函数(类)的源代码。。。已经知道怎么用gdb跟进eglibc的源码。。。
头像
astolia
论坛版主
帖子: 4602
注册时间: 2008-09-18 13:11
送出感谢: 1 次
接收感谢: 771 次

Re: gdb调式跟踪libstdc++代码

#2

帖子 astolia » 2014-09-16 21:39

安装对应的调试符号包以及libstdc++源码。调试符号包名以-dbg结尾,libstdc++6-X.X-dbg,X.X是版本号
ubuntufree
帖子: 7
注册时间: 2014-04-04 23:09
系统: Windows+ubuntu
送出感谢: 0
接收感谢: 0

Re: gdb调式跟踪libstdc++代码

#3

帖子 ubuntufree » 2014-09-17 16:07

安装好了源码和dbg包,但是gdb貌似搜索的路径和libstdc++的源码路径不一样,弄了好久也没有设置好,该怎么设置gdb的搜索路径?为什么gdb搜索路径和stdc++的源码路径不一样?(libstdc++包含在gcc的源码里,gcc名称为gcc-4.8.2,gdb里是gcc-4.8-4.8.2,glibc则没有出现此类问题)
头像
astolia
论坛版主
帖子: 4602
注册时间: 2008-09-18 13:11
送出感谢: 1 次
接收感谢: 771 次

Re: gdb调式跟踪libstdc++代码

#4

帖子 astolia » 2014-09-17 23:31

(gdb) help files
Specifying and examining files.

List of commands:

add-symbol-file -- Load symbols from FILE
add-symbol-file-from-memory -- Load the symbols out of memory from a dynamically loaded object file
cd -- Set working directory to DIR for debugger and program being debugged
core-file -- Use FILE as core dump for examining memory and registers
directory -- Add directory DIR to beginning of search path for source files
edit -- Edit specified file or function
exec-file -- Use FILE as program for getting contents of pure memory
file -- Use FILE as program to be debugged
forward-search -- Search for regular expression (see regex(3)) from last line listed
generate-core-file -- Save a core file with the current state of the debugged process
list -- List specified function or line
load -- Dynamically load FILE into the running program
nosharedlibrary -- Unload all shared object library symbols
path -- Add directory DIR(s) to beginning of search path for object files
pwd -- Print working directory
remote -- Manipulate files on the remote system
remote delete -- Delete a remote file
remote get -- Copy a remote file to the local system
remote put -- Copy a local file to the remote system
remove-symbol-file -- Remove a symbol file added via the add-symbol-file command
reverse-search -- Search backward for regular expression (see regex(3)) from last line listed
search -- Search for regular expression (see regex(3)) from last line listed
section -- Change the base address of section SECTION of the exec file to ADDR
sharedlibrary -- Load shared object library symbols for files matching REGEXP
symbol-file -- Load symbol table from executable file FILE

(gdb) help directory
Add directory DIR to beginning of search path for source files.
Forget cached info on source file locations and line positions.
DIR can also be $cwd for the current working directory, or $cdir for the
directory in which the source file was compiled into object code.
With no argument, reset the search path to $cdir:$cwd, the default.
用gdb的gui前端如nemiver、ddd之类会自动告诉你该把源文件放到哪里
回复

回到 “软件/网站开发”