码迷,mamicode.com
首页 > 其他好文 > 详细

debug 2

时间:2019-04-23 21:03:37      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:dual   symbols   round   block   end   HERE   c++11   format   pen   

 

Red Hat Developer Toolset
delivers the latest stable versions of essential GCC C, C++, Fortran, and supporting development
tools to enhance developer productivity and improve deployment times.

About GCC version, recommend to use the latest version,
wihle adding new features to compiler, it may introduce some ABI changes and new defects(especially c++11)
if we use a third-party lib complied with gcc of a different version, sometimes it may cause link failure(backwards compatibility).
https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html (part 3)
https://gcc.gnu.org/wiki/Cxx11AbiCompatibility
https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

linux so information:
readelf vs objdump : recommend to use readelf
https://stackoverflow.com/questions/8979664/readelf-vs-objdump-why-are-both-needed

direct dependency: readelf -d
recursive ones : ldd

elf sections: .comment debug symtab text
gcc version : readelf -p .comment elf-file

check whether elf is compiled with ‘-g‘ (debugging)
1) use gdb
2) readelf -S elf //to see if there are .debug_x sections
- readelf --debug-dump=decodeline elf // to show section:.debug_line

3)if Elf are built with ‘-gsplit-dwarf‘, it would generate *.dwo to contain debug info
find its path in .debug_str

 


 

Windbg 概念

Local cache     MS Symbol Store     Symbol (search) Path

.symfix (path) : 把 Store 覆盖 Symbol Path (不需要记忆官方地址)

.symfix+ path : 把Store 添加到已有Symbol Path

.sympath (path) : 显示(覆盖)当前Symbol Path

Source: src path 只要相对路径不被破坏,只需指定一处(源文件的根目录),windbg会自动关联。

-        需要的src path通常是包含在pdb文件中,只有在加载pdb后可知,比如打印堆

技术图片

load executable/ dump file / attach to process

lm 查看模块及是否加载symbol

!lmi module-name 查看模块的symbol 位置

 

~ 显示thread数  ~ NO. S  切换thread

 

 K显示堆   .frame NO.  前往指定堆

 

查找符号断点

-        根据k 显示的符号

-        X [<*|module>!]<*|symbol> - view symbols

Bp  function-name  & bc 删除

 

打开源文件, 如果没设置对路径,无反应

.open  -a function-name

 

 

 

调试

g – run  p – step over t – step in

 

查看变量

dv varialble

 

 

i sh 查看加载的动态模块

 

Info threads 查看线程 thread NO. 切换线程

 

bt 堆      frame NO 前往指定堆

 

查看符号断点

-        Info functions 查看有的符号

-        b functon-name  / delete NO. 删除断点

-        info b 查看breakpoints 

 

Info sources 查看引用source 路径   Show directories 来查看source search path

使用set directories / substitute-path 来设置目录 

List -  当前行

list function / NO.

 

Debug

r – run   n – step over  s  - step into   c - continue

 

Variables

p variable  set variable = new-v

提供了 查看map, list 命令

Info args  / where  / condition  / (force) return

 

 

debug 2

标签:dual   symbols   round   block   end   HERE   c++11   format   pen   

原文地址:https://www.cnblogs.com/resibe-3/p/10758658.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!