您的位置:首页技术开发java教程 → 使用GDB调试RB-tree的问题总汇

使用GDB调试RB-tree的问题总汇

时间:2011/7/12 8:20:15来源:本站原创作者:清晨我要评论(1)

2 页 如何通过目标文件

3. 如何通过目标文件.o或者可执行文件得知是否有debugging information?

可通过如下命令查看debugguing information。

objdump -g filename

objdump -h filename(查看有无debug section)

nm -l filename

重新编译gcc-4.1.2的源文件tree.cc,观看结果。

# cd /mnt/hgfs/edisk/opensource/gcc-4.1.2/libstdc++-v3/src

# g++ -o tree.o -c tree.cc  //without debugging information

# objdump -h tree.o

tree.o:     file format elf32-i386

Sections:

Idx Name          Size      VMA       LMA       File off  Algn

  0 .group        00000008  00000000  00000000  00000034  2**2

                  CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD

  1 .group        00000008  00000000  00000000  0000003c  2**2

                  CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD

  2 .group        00000008  00000000  00000000  00000044  2**2

                  CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD

  3 .text         00000952  00000000  00000000  0000004c  2**2

                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE

  4 .data         00000000  00000000  00000000  000009a0  2**2

                  CONTENTS, ALLOC, LOAD, DATA

  5 .bss          00000000  00000000  00000000  000009a0  2**2

                  ALLOC

  6 .text._ZNSt18_Rb_tree_node_base10_S_minimumEPS_ 00000022  00000000  00000000  000009a0  2**0

                  CONTENTS, ALLOC, LOAD, READONLY, CODE

  7 .text._ZNSt18_Rb_tree_node_base10_S_maximumEPS_ 00000022  00000000  00000000  000009c2  2**0

                  CONTENTS, ALLOC, LOAD, READONLY, CODE

  8 .text._ZSt4swapISt14_Rb_tree_colorEvRT_S2_ 00000022  00000000  00000000  000009e4  2**0

                  CONTENTS, ALLOC, LOAD, READONLY, CODE

  9 .comment      00000024  00000000  00000000  00000a06  2**0

                  CONTENTS, READONLY

10 .note.GNU-stack 00000000  00000000  00000000  00000a2a  2**0

                  CONTENTS, READONLY

11 .eh_frame     0000016c  00000000  00000000  00000a2c  2**2

                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA

# cd /mnt/hgfs/edisk/opensource/gcc-4.1.2/libstdc++-v3/src

# g++ -g -o tree.d.o -c tree.cc  //with debugging information

# objdump -h tree.d.o

tree.d.o:     file format elf32-i386

Sections:

Idx Name          Size      VMA       LMA       File off  Algn

  0 .group        00000008  00000000  00000000  00000034  2**2

                  CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD

  1 .group        00000008  00000000  00000000  0000003c  2**2

                  CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD

  2 .group        00000008  00000000  00000000  00000044  2**2

                  CONTENTS, READONLY, EXCLUDE, GROUP, LINK_ONCE_DISCARD

  3 .text         00000952  00000000  00000000  0000004c  2**2

                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE

  4 .data         00000000  00000000  00000000  000009a0  2**2

                  CONTENTS, ALLOC, LOAD, DATA

  5 .bss          00000000  00000000  00000000  000009a0  2**2

                  ALLOC

  6 .debug_abbrev 000001d0  00000000  00000000  000009a0  2**0

                  CONTENTS, READONLY, DEBUGGING

  7 .debug_info   000006fd  00000000  00000000  00000b70  2**0

                  CONTENTS, RELOC, READONLY, DEBUGGING

  8 .debug_line   00000258  00000000  00000000  0000126d  2**0

                  CONTENTS, RELOC, READONLY, DEBUGGING

  9 .text._ZNSt18_Rb_tree_node_base10_S_minimumEPS_ 00000022  00000000  00000000  000014c5  2**0

                  CONTENTS, ALLOC, LOAD, READONLY, CODE

10 .text._ZNSt18_Rb_tree_node_base10_S_maximumEPS_ 00000022  00000000  00000000  000014e7  2**0

                  CONTENTS, ALLOC, LOAD, READONLY, CODE

11 .text._ZSt4swapISt14_Rb_tree_colorEvRT_S2_ 00000022  00000000  00000000  00001509  2**0

                  CONTENTS, ALLOC, LOAD, READONLY, CODE

12 .debug_loc    00000210  00000000  00000000  0000152b  2**0

                  CONTENTS, RELOC, READONLY, DEBUGGING

13 .debug_pubnames 0000019d  00000000  00000000  0000173b  2**0

                  CONTENTS, RELOC, READONLY, DEBUGGING

14 .debug_aranges 00000038  00000000  00000000  000018d8  2**0

                  CONTENTS, RELOC, READONLY, DEBUGGING

15 .debug_ranges 00000070  00000000  00000000  00001910  2**0

                  CONTENTS, RELOC, READONLY, DEBUGGING

16 .debug_str    00000533  00000000  00000000  00001980  2**0

                  CONTENTS, READONLY, DEBUGGING

17 .comment      00000024  00000000  00000000  00001eb3  2**0

                  CONTENTS, READONLY

18 .note.GNU-stack 00000000  00000000  00000000  00001ed7  2**0

                  CONTENTS, READONLY

19 .eh_frame     0000016c  00000000  00000000  00001ed8  2**2

                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, DATA

以下是nm命令的结果。

  -l, --line-numbers     Use debugging information to find a filename and

                           line number for each symbol

# cd /mnt/hgfs/edisk/opensource/gcc-4.1.2/libstdc++-v3/src

# nm -l tree.o

00000000 W _ZNSt18_Rb_tree_node_base10_S_maximumEPS_

00000000 W _ZNSt18_Rb_tree_node_base10_S_minimumEPS_

0000011a T _ZSt18_Rb_tree_decrementPKSt18_Rb_tree_node_base

00000088 T _ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base

00000075 T _ZSt18_Rb_tree_incrementPKSt18_Rb_tree_node_base

00000000 T _ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base

00000910 T _ZSt20_Rb_tree_black_countPKSt18_Rb_tree_node_baseS1_

0000012d T _ZSt20_Rb_tree_rotate_leftPSt18_Rb_tree_node_baseRS0_

000001ba T _ZSt21_Rb_tree_rotate_rightPSt18_Rb_tree_node_baseRS0_

0000046f T _ZSt28_Rb_tree_rebalance_for_erasePSt18_Rb_tree_node_baseRS_

00000247 T _ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_

00000000 W _ZSt4swapISt14_Rb_tree_colorEvRT_S2_

         U __gxx_personality_v0

# cd /mnt/hgfs/edisk/opensource/gcc-4.1.2/libstdc++-v3/src

# nm -l tree.d.o  //tree.d.o有debugging information

00000000 W _ZNSt18_Rb_tree_node_base10_S_maximumEPS_    /usr/include/c++/4.4/bits/stl_tree.h:112

00000000 W _ZNSt18_Rb_tree_node_base10_S_minimumEPS_    /usr/include/c++/4.4/bits/stl_tree.h:98

0000011a T _ZSt18_Rb_tree_decrementPKSt18_Rb_tree_node_base     /mnt/hgfs/edisk/opensource/gcc-4.1.2/libstdc++-v3/src/tree.cc:119

00000088 T _ZSt18_Rb_tree_decrementPSt18_Rb_tree_node_base      /mnt/hgfs/edisk/opensource/gcc-4.1.2/libstdc++-v3/src/tree.cc:93

00000075 T _ZSt18_Rb_tree_incrementPKSt18_Rb_tree_node_base     /mnt/hgfs/edisk/opensource/gcc-4.1.2/libstdc++-v3/src/tree.cc:87

00000000 T _ZSt18_Rb_tree_incrementPSt18_Rb_tree_node_base      /mnt/hgfs/edisk/opensource/gcc-4.1.2/libstdc++-v3/src/tree.cc:64

00000910 T _ZSt20_Rb_tree_black_countPKSt18_Rb_tree_node_baseS1_        /mnt/hgfs/edisk/opensource/gcc-4.1.2/libstdc++-v3/src/tree.cc:416

0000012d T _ZSt20_Rb_tree_rotate_leftPSt18_Rb_tree_node_baseRS0_        /mnt/hgfs/edisk/opensource/gcc-4.1.2/libstdc++-v3/src/tree.cc:126

000001ba T _ZSt21_Rb_tree_rotate_rightPSt18_Rb_tree_node_baseRS0_       /mnt/hgfs/edisk/opensource/gcc-4.1.2/libstdc++-v3/src/tree.cc:147

0000046f T _ZSt28_Rb_tree_rebalance_for_erasePSt18_Rb_tree_node_baseRS_ /mnt/hgfs/edisk/opensource/gcc-4.1.2/libstdc++-v3/src/tree.cc:259

00000247 T _ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_    /mnt/hgfs/edisk/opensource/gcc-4.1.2/libstdc++-v3/src/tree.cc:170

00000000 W _ZSt4swapISt14_Rb_tree_colorEvRT_S2_ /usr/include/c++/4.4/bits/move.h:76

# c++filt _ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_

std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&)

从以上结果可以看出,在tree.d.o中,每个函数都有对应的调试信息,例如在源文件(tree.cc)中的行号。

本文导航

相关视频

    没有数据

相关阅读 使用时间倒流功能,每消除1个可以增加几秒时间? 天天爱消除2月1H1Z1熔炉怎么点燃 H1Z1熔炉制作及使用方法龙之谷手游怎么用电脑玩 龙之谷手游电脑版使用教程三国志13威力加强版破解了吗 三国志13威力加强版破解补丁使用方法美团打车怎样加入 美团打车怎么使用命运冠位指定圣晶石怎么使用 FGO圣晶石使用方法仁王枪加点攻略 仁王枪使用心得技巧小米直供模式怎么使用 小米直供使用方法介绍

文章评论
发表评论

热门文章 没有查询到任何记录。

最新文章 myeclipse如何安装插件myeclipse怎么显示代码 myeclipse怎么连接到数据库 myeclipse连接到eclipse没有maven选项怎么办 eclipse没有majava设置cookie教程 java怎么设置cookiejava怎么设置随机数 java设置随机数详细教程

人气排行 java.lang.NullPointerException错误处理方eclipse没有maven选项怎么办 eclipse没有majava环境变量配置方法java中String类主要方法的使用java中创建并初始化字符串方法MyEclipse的注册以及汉化方法图解myeclipse如何安装插件 myeclipse安装插件方一个简单Java发邮件源代码