日期:2014-05-16  浏览次数:20617 次

GDB 调试相关

之前利用gdb查看内存数据,定位到了一个内存泄露的问题,但是没有很好的将一些当时用到的资料收集起来,这次汇集下以便以后参考:

?

1:Debugging with?gdb

http://sourceware.org/gdb/download/onlinedocs/gdb/index.html

?

2:GNU GDB Debugger Command Cheat Sheet

http://www.yolinux.com/TUTORIALS/GDB-Commands.html

?

?

3:GDB调试器

http://www.ruchee.com/code/linux/gnu/gdb.html

?

?

gdb转储内存使用到的命令参考自:

http://sourceware.org/gdb/onlinedocs/gdb/Logging-Output.html

?

set logging on
Enable logging.?
set logging off
Disable logging.?
set logging file?file
Change the name of the current logfile. The default logfile is?gdb.txt.?
set logging overwrite [on|off]
By default,?gdb?will append to the logfile. Set?overwrite?if you want?set logging on?to overwrite the logfile instead.?
set logging redirect [on|off]
By default,?gdb?output will go to both the terminal and the logfile. Set?redirect?if you want output to go only to the log file.?
show logging
Show the current values of the logging settings.

?

gdb内存查看参考自:

1:?Examining Memory

http://sourceware.org/gdb/onlinedocs/gdb/Memory.html#Memory

?

2:Output Formats

http://sourceware.org/gdb/onlinedocs/gdb/Output-Formats.html#Output-Formats

?

简单的gdb内存转储的例子如下:

>> set logging on
>> x/[n][format]  startHexAddress

?结果是生成一个gdb.txt的默认文件。

?n是指需要从起始地址转储多少单位内存数据,例如假设需要查看的数据是4*1024 byte,然后按照byte的大小来查看, 则n需要设置为4*1024