gdb调试问题No executable file specified.

c372662316 2011-07-03 04:41:40
我在makefile文件中加入了-g但还是出现No executable file specified.求解!
makefile 内容如下

myprogram :main.o dib.o
g++ -g -o myprogram main.o dib.o
main.o :main.cpp main.h dib.h
g++ -g -c main.cpp
dib.o : dib.cpp dib.h bmp.h main.h
g++ -g -c dib.cpp
clean :
rm myprogram main.o dib.o
...全文
4593 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
c372662316 2011-07-03
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 hqin6 的回复:]

你写run xxxx
后面那个xxxx会被认为是命令行参数!
[/Quote]
Thankyou 解决,原来是在进入gdb时 gdb myprogram,
结贴给分
太乙 2011-07-03
  • 打赏
  • 举报
回复
你写run xxxx
后面那个xxxx会被认为是命令行参数!
太乙 2011-07-03
  • 打赏
  • 举报
回复 2
第一种方式不对!
可以使用
gdb a.out
run
或者:
gdb
file a.out
run
[Quote=引用 5 楼 c372662316 的回复:]

引用 3 楼 hqin6 的回复:

lz
如何进行的gdb调试?
进入gdb后, run myprogram
他就显示No executable file specified
但是我可以直接用file myprogram调试;
但是不加-g 也可以file myprogram调试
[/Quote]
c372662316 2011-07-03
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 hqin6 的回复:]

lz
如何进行的gdb调试?
[/Quote]进入gdb后, run myprogram
他就显示No executable file specified
但是我可以直接用file myprogram调试;
但是不加-g 也可以file myprogram调试
yfk 2011-07-03
  • 打赏
  • 举报
回复
怀疑LZ运行gdb命令时出错~
太乙 2011-07-03
  • 打赏
  • 举报
回复
lz
如何进行的gdb调试?
c372662316 2011-07-03
  • 打赏
  • 举报
回复
求解阿,木有人知道吗
Table of Contents Summary of GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Free software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Contributors to GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 A Sample GDB Session . . . . . . . . . . . . . . . . . . . . 5 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 2 Loading the Executable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Setting Display width. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Setting Breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Running the executable under GDB . . . . . . . . . . . . . . . . . . . . . . Stepping to the next line in the source program . . . . . . . . . . . . Stepping into a subroutine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Examining the Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Printing Variable Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Listing Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Setting Variable Values During a Session . . . . . . . . . . . . . . . . . Getting In and Out of GDB . . . . . . . . . . . . . . . 11 2.1 Invoking GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 Choosing files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.2 Choosing modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.3 Redirecting WDB input and output to a file . . . . . 2.2 Quitting GDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Shell commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 5 6 6 6 6 6 7 7 7 8 11 11 13 15 15 16 GDB Commands . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.1 Command syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.2 Command completion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.3 Getting help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 4 Running Programs Under GDB . . . . . . . . . . . 23 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10 Compiling for debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Starting your program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Arguments To Your Program. . . . . . . . . . . . . . . . . . . . . . . . . . . . Program Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Working directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Program Input and Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Debugging a Running Process . . . . . . . . . . . . . . . . . . . . . . . . . . . Killing the child process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Debugging programs with multiple threads . . . . . . . . . . . . . . . Debugging programs with multiple processes . . . . . . . . . . . . 23 23 24 25 26 26 27 28 28 31 ii 5 Debugging with GDB Stopping and Continuing . . . . . . . . . . . . . . . . . . 33 5.1 Breakpoints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.1 Setting breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.2 Setting catchpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.3 Deleting breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.4 Disabling breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.5 Break conditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.6 Breakpoint command lists . . . . . . . . . . . . . . . . . . . . . . 5.1.7 Breakpoint menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1.8 “Cannot insert breakpoints” . . . . . . . . . . . . . . . . . . . . 5.2 Continuing and stepping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3 Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.4 Stopping and starting multi-thread programs . . . . . . . . . . . . . 6 Examining the Stack . . . . . . . . . . . . . . . . . . . . . . 51 6.1 6.2 6.3 6.4 6.5 6.6 7 Stack frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Stacks Without frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Commands for Examining the Stack . . . . . . . . . . . . . . . . . . . . . Backtraces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Selecting a frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Information about a frame . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 51 52 52 53 54 Examining Source Files . . . . . . . . . . . . . . . . . . . 57 7.1 7.2 7.3 7.4 8 33 33 37 38 39 40 41 42 43 43 46 48 Printing source lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Searching source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Specifying source directories . . . . . . . . . . . . . . . . . . . . . . . . . . . . Source and machine code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 58 59 59 Examining Data . . . . . . . . . . . . . . . . . . . . . . . . . . 63 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 8.10 8.11 8.12 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Program variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Artificial arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Output formats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Examining memory. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Automatic display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Print settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Value history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Convenience variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Printing Floating Point Values . . . . . . . . . . . . . . . . . . . . . . . . . Floating point hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 64 65 66 67 68 70 74 75 76 78 78 iii 9 Using GDB with Different Languages . . . . . . 79 9.1 Switching between source languages . . . . . . . . . . . . . . . . . . . . . 9.1.1 List of filename extensions and languages . . . . . . . . 9.1.2 Setting the working language . . . . . . . . . . . . . . . . . . . 9.1.3 Having GDB infer the source language . . . . . . . . . . 9.2 Displaying the language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.3 Type and range checking. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.3.1 An overview of type checking . . . . . . . . . . . . . . . . . . . 9.3.2 An overview of range checking . . . . . . . . . . . . . . . . . . 9.4 Supported languages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.4.1 C and C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.4.1.1 C and C++ operators . . . . . . . . . . . . . . . . . . 9.4.1.2 C and C++ constants . . . . . . . . . . . . . . . . . . 9.4.1.3 C++ expressions . . . . . . . . . . . . . . . . . . . . . . . 9.4.1.4 C and C++ defaults . . . . . . . . . . . . . . . . . . . 9.4.1.5 C and C++ type and range checks . . . . . . 9.4.1.6 GDB and C . . . . . . . . . . . . . . . . . . . . . . . . . . 9.4.1.7 GDB features for C++ . . . . . . . . . . . . . . . . . 9.4.2 Fortran . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9.4.2.1 Fortran types . . . . . . . . . . . . . . . . . . . . . . . . . 9.4.2.2 Fortran operators . . . . . . . . . . . . . . . . . . . . . 9.4.2.3 Fortran special issues . . . . . . . . . . . . . . . . . . 79 79 80 80 80 81 81 82 83 83 84 85 86 87 88 88 88 89 90 90 91 10 Examining the Symbol Table . . . . . . . . . . . . . 93 11 Altering Execution . . . . . . . . . . . . . . . . . . . . . . 97 11.1 11.2 11.3 11.4 11.5 11.6 12 Assignment to variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 Continuing at a different address . . . . . . . . . . . . . . . . . . . . . . . 98 Giving your program a signal . . . . . . . . . . . . . . . . . . . . . . . . . . 99 Returning from a function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 Calling program functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 Patching programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 GDB Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 12.1 Commands to specify files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 12.2 Specifying shared library locations . . . . . . . . . . . . . . . . . . . . . 106 12.3 Errors reading symbol files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 13 Specifying a Debugging Target . . . . . . . . . . 109 13.1 Active targets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 13.2 Commands for managing targets . . . . . . . . . . . . . . . . . . . . . . 109 13.3 Choosing target byte order. . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 iv 14 Debugging with GDB HP-UX Configuration-Specific Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 14.1 Summary of HP Enhancements to GDB . . . . . . . . . . . . . . . 113 14.2 HP-UX dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 14.2.1 Linker Dependencies . . . . . . . . . . . . . . . . . . . . . . . . . 115 14.2.2 Dependent Standard Library Routines for Run Time Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 14.3 Supported Platforms and Modes . . . . . . . . . . . . . . . . . . . . . . 117 14.4 HP-UX targets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 14.5 Support for Alternate root . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 14.6 Specifying object file directories . . . . . . . . . . . . . . . . . . . . . . . 118 14.7 Fix and continue debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 14.7.1 Fix and Continue compiler dependencies . . . . . . 120 14.7.2 Fix and Continue restrictions . . . . . . . . . . . . . . . . . 121 14.7.3 Using Fix and Continue . . . . . . . . . . . . . . . . . . . . . . 121 14.7.4 Example Fix and Continue session . . . . . . . . . . . . 122 14.8 Inline Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 14.8.1 Inline Debugging in HP 9000 Systems . . . . . . . . . 124 14.8.2 Inline Debugging in Integrity Systems . . . . . . . . . 125 14.8.2.1 Debugging Inline Functions in Integrity Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126 14.9 Debugging memory problems . . . . . . . . . . . . . . . . . . . . . . . . . 128 14.9.1 When to suspect a memory leak . . . . . . . . . . . . . . 128 14.9.2 Memory debugging restrictions . . . . . . . . . . . . . . . 128 14.9.3 Memory Debugging Methodologies . . . . . . . . . . . . 128 14.9.4 Debugging Memory in Interactive Mode . . . . . . . 129 14.9.4.1 Commands for interactive memory debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 14.9.4.2 Example for interactive debugging session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 14.9.5 Debugging Memory in Batch Mode . . . . . . . . . . . 133 14.9.5.1 Setting Configuration Options for Batch Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 14.9.5.2 Environment variable setting for Batch mode debugging . . . . . . . . . . . . . . . . . . . . . . . . . 134 14.9.5.3 Example for Batch Mode RTC . . . . . . . 135 14.9.6 Debugging Memory Interactively After Attaching to a Running Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 14.9.7 Configuring memory debugging settings . . . . . . . 137 14.9.7.1 Specifying the stack depth . . . . . . . . . . . 137 14.9.7.2 Specifying minimum leak size . . . . . . . . 138 14.9.7.3 Specifying minimum block size . . . . . . . 138 14.9.8 Scenarios in memory debugging . . . . . . . . . . . . . . . 138 14.9.8.1 Stop when freeing unallocated or deallocated blocks . . . . . . . . . . . . . . . . . . . . . . . 138 14.9.8.2 Stop when freeing a block if bad writes occurred outside block boundary . . . . . . . . . . 138 v 14.9.8.3 Stop when a specified block address is allocated or deallocated . . . . . . . . . . . . . . . . . . 139 14.9.8.4 Scramble previous memory contents at malloc/free calls . . . . . . . . . . . . . . . . . . . . . . . . . 139 14.9.9 Comparison of Memory Debugging Commands in Interactive Mode and Batch Mode . . . . . . . . . . . . . . . 140 14.9.10 Heap Profiling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 14.9.10.1 Commands for heap profiling . . . . . . . 142 14.9.10.2 info heap arena . . . . . . . . . . . . . . . . . . 143 14.9.10.3 info heap arena [0 |1|2|..] blocks stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 14.9.10.4 info module ADDRESS . . . . . . . . . . . . . . 143 14.9.10.5 info heap process . . . . . . . . . . . . . . . . 143 14.9.10.6 Example for heap profiling . . . . . . . . . . 143 14.9.11 Memory Checking Analysis for User Defined Memory Management Routines . . . . . . . . . . . . . . . . . . 144 14.9.12 Commands to track the change in data segment value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 14.10 Thread Debugging Support . . . . . . . . . . . . . . . . . . . . . . . . . . 145 14.10.1 Support for Enabling and Disabling Specific Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 14.10.2 Backtrace Support for Thread Debugging . . . . 146 14.10.3 Advanced Thread Debugging Support . . . . . . . . 146 14.10.3.1 Pre-requisites for Advanced Thread Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 14.10.3.2 Enabling and Disabling Advanced Thread Debugging Features. . . . . . . . . . . . . . . 148 14.10.3.3 Commands to view information on pthread primitives . . . . . . . . . . . . . . . . . . . . . . . 150 14.11 Debugging MPI Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 14.12 Debugging multiple processes ( programs with fork and vfork calls) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 14.12.1 Ask mode for set follow-fork-mode . . . . . . . . 151 14.12.2 serial mode for set follow-fork-mode . . . . . . . 151 14.12.3 Support for showing unwind info. . . . . . . . . . . . . 151 14.12.4 Printing CFM and PFS registers. . . . . . . . . . . . . 152 14.13 Debugging Core Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 14.13.1 Generating core files with packcore /unpackcore/getcore . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 14.13.2 Support for the dumpcore command . . . . . . . . . 153 14.13.2.1 Enhancements to the dumpcore command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 14.14 Invoking GDB Before a Program Aborts . . . . . . . . . . . . . . 154 14.15 Instruction Level Stepping . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 14.16 Enhanced support for watchpoints and breakpoints . . . . 155 14.16.1 Deferred watchpoints . . . . . . . . . . . . . . . . . . . . . . . 155 14.16.2 Hardware watchpoints . . . . . . . . . . . . . . . . . . . . . . 155 14.16.3 Hardware breakpoints . . . . . . . . . . . . . . . . . . . . . . 155 vi Debugging with GDB 14.17 14.18 14.19 14.20 14.21 14.22 14.23 14.16.3.1 Setting breakpoints in unstripped shared library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 14.16.4 Support for procedural breakpoints . . . . . . . . . . 155 14.16.5 Support for template breakpoints . . . . . . . . . . . . 156 Debugging support for shared libraries . . . . . . . . . . . . . . . . 156 14.17.1 Using shared library as main program . . . . . . . . 157 14.17.2 Setting Deferred Breakpoints in Shared Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 14.17.3 Using catch load . . . . . . . . . . . . . . . . . . . . . . . . . . 158 14.17.4 Privately mapping shared libraries . . . . . . . . . . . 158 14.17.5 Selectively Mapping Shared Libraries As Private . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 14.17.6 Setting breakpoints in shared library . . . . . . . . . 159 Language support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 14.18.1 Enhanced Java Debugging Support . . . . . . . . . . 159 14.18.2 Commands for Examining Java Virtual Machine(JVM) internals . . . . . . . . . . . . . . . . . . . . . . . . . 159 14.18.2.1 Java subcommands . . . . . . . . . . . . . . . . 160 14.18.3 Support for stack traces in Java, C, and C++ programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160 14.18.4 Support for 64-bit Java, C, aC++ stack unwinding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 14.18.5 Enhanced support for C++ templates . . . . . . . . . 161 14.18.6 Support for __fpreg data type on IPF . . . . . . . 162 14.18.7 Support for Complex variables in HP C . . . . . 162 14.18.8 Support for debugging namespaces . . . . . . . . . . . 163 14.18.9 Command for evaluating the address of an expression . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 Viewing Wide Character Strings . . . . . . . . . . . . . . . . . . . . . 163 Support for output logging . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 14.20.1 Support for dumping array in an ASCII file . . 164 14.20.2 Support for Fortran array slices . . . . . . . . . . . . . . 165 14.20.3 Displaying enumerators . . . . . . . . . . . . . . . . . . . . . 165 14.20.4 Support for debugging typedefs . . . . . . . . . . . . . . 165 14.20.5 Support for steplast command for C and C++ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Getting information from a non-debug executable . . . . . 166 Debugging optimized code . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 14.22.1 Debugging Optimized Code at Various Optimization Levels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 14.22.1.1 +O0 and +O1 . . . . . . . . . . . . . . . . . . . . . . . 169 14.22.1.2 +O2 and +O3 . . . . . . . . . . . . . . . . . . . . . . . 169 14.22.1.3 +O4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 Visual Interface for WDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 14.23.1 Starting and stopping Visual Interface for WDB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 14.23.2 Navigating the Visual Interface for WDB display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 vii 14.23.3 Specifying foreground and background colors . . 172 14.23.4 Using the X-window graphical interface . . . . . . 173 14.23.5 Using the TUI mode . . . . . . . . . . . . . . . . . . . . . . . . 173 14.23.6 Changing the size of the source or debugger pane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 14.23.7 Using commands to browse through source files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 14.23.8 Loading source files . . . . . . . . . . . . . . . . . . . . . . . . . 175 14.23.9 Editing source files . . . . . . . . . . . . . . . . . . . . . . . . . 175 14.23.10 Editing the command line and command-line history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 14.23.11 Saving the contents of a debugging session to a file. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175 14.24 Support for ddd. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 14.25 Support for XDB commands . . . . . . . . . . . . . . . . . . . . . . . . . 176 14.25.1 stop in/at dbx commands . . . . . . . . . . . . . . . . . . . 176 14.26 GNU GDB Logging Commands . . . . . . . . . . . . . . . . . . . . . . 176 14.27 Support for command line calls in a stripped executable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176 14.27.1 Support for command line calls in a stripped executable on PA-RISC systems . . . . . . . . . . . . . . . . . 176 14.27.2 Additional support for command line calls in a stripped executable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 14.27.2.1 For 32-bit applications: . . . . . . . . . . . . . 177 14.27.2.2 For 64-bit applications . . . . . . . . . . . . . 177 14.27.3 Support for debugging stripped binaries . . . . . . 178 14.27.3.1 Printing of locals and globals in a stripped module . . . . . . . . . . . . . . . . . . . . . . . . . 178 14.27.3.2 Backtrace on stripped frames . . . . . . . 178 14.27.3.3 Command line calls to non-stripped library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 14.27.3.4 Setting breakpoints in unstripped shared library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 14.28 Displaying the current block scope information . . . . . . . . 178 14.29 Linux support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 15 The HP-UX Terminal User Interface. . . . . 181 15.1 Starting the TUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.2 Automatically running a program at startup . . . . . . . . . . . 15.3 Screen Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.3.1 Source pane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.3.2 Disassembly pane . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.3.3 Source/Disassembly pane . . . . . . . . . . . . . . . . . . . . 15.3.4 Disassembly/Register pane . . . . . . . . . . . . . . . . . . . 15.3.5 Source/Register pane . . . . . . . . . . . . . . . . . . . . . . . . 15.4 Cycling through the panes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.5 Changing pane focus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15.6 Scrolling panes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 182 183 183 183 184 185 186 187 187 190 viii Debugging with GDB 15.7 Changing the register display . . . . . . . . . . . . . . . . . . . . . . . . . 190 15.8 Changing the pane size . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 15.9 Refreshing and updating the window . . . . . . . . . . . . . . . . . . 193 16 XDB to WDB Transition Guide . . . . . . . . . 195 16.1 By-function lists of XDB commands and HP WDB equivalents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 16.1.1 Invocation commands . . . . . . . . . . . . . . . . . . . . . . . . 196 16.1.2 Window mode commands . . . . . . . . . . . . . . . . . . . . 196 16.1.3 File viewing commands . . . . . . . . . . . . . . . . . . . . . . 197 16.1.4 Source directory mapping commands . . . . . . . . . . 198 16.1.5 Data Viewing and modification commands. . . . . 199 16.1.6 Stack viewing commands . . . . . . . . . . . . . . . . . . . . . 201 16.1.7 Status-viewing command . . . . . . . . . . . . . . . . . . . . . 201 16.1.8 Job control commands . . . . . . . . . . . . . . . . . . . . . . . 202 16.2 Overall breakpoint commands . . . . . . . . . . . . . . . . . . . . . . . . . 203 16.2.1 Auxiliary breakpoint commands . . . . . . . . . . . . . . 203 16.2.2 Breakpoint creation commands . . . . . . . . . . . . . . . 204 16.2.3 Breakpoint status commands . . . . . . . . . . . . . . . . . 205 16.2.4 All-procedures breakpoint commands . . . . . . . . . 206 16.2.5 Global breakpoint commands . . . . . . . . . . . . . . . . . 207 16.2.6 Assertion control commands . . . . . . . . . . . . . . . . . . 207 16.2.7 Record and playback commands . . . . . . . . . . . . . . 207 16.2.8 Macro facility commands . . . . . . . . . . . . . . . . . . . . . 208 16.2.9 Signal control commands . . . . . . . . . . . . . . . . . . . . . 208 16.2.10 Miscellaneous commands . . . . . . . . . . . . . . . . . . . . 209 16.3 XDB data formats and HP WDB equivalents . . . . . . . . . . . 210 16.4 XDB location syntax and HP WDB equivalents . . . . . . . . 212 16.5 XDB special language operators and HP WDB equivalents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 16.6 XDB special variables and HP WDB equivalents. . . . . . . . 213 16.7 XDB variable identifiers and HP WDB equivalents. . . . . . 215 16.8 Alphabetical lists of XDB commands and HP WDB equivalents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 16.8.1 A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 16.8.2 B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216 16.8.3 C through D . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 16.8.4 F through K . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 16.8.5 L . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 16.8.6 M through P . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221 16.8.7 Q through S . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 16.8.8 T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 16.8.9 U through Z . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 16.8.10 Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226 ix 17 Controlling GDB . . . . . . . . . . . . . . . . . . . . . . . 231 17.1 17.2 17.3 17.4 17.5 17.6 17.7 18 Setting the GDB Prompt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Setting Command Editing Options in GDB . . . . . . . . . . . . Setting Command History Feature in GDB . . . . . . . . . . . . . Setting the GDB Screen Size . . . . . . . . . . . . . . . . . . . . . . . . . . Supported Number Formats. . . . . . . . . . . . . . . . . . . . . . . . . . . Optional warnings and messages . . . . . . . . . . . . . . . . . . . . . . Optional messages about internal happenings. . . . . . . . . . . 231 231 231 233 233 234 235 Canned Sequences of Commands . . . . . . . . 237 18.1 18.2 18.3 18.4 User-defined commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . User-defined command hooks . . . . . . . . . . . . . . . . . . . . . . . . . Command files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Commands for controlled output . . . . . . . . . . . . . . . . . . . . . . 237 238 239 239 19 Using GDB under gnu Emacs . . . . . . . . . . . 241 20 GDB Annotations . . . . . . . . . . . . . . . . . . . . . . 243 20.1 20.2 20.3 20.4 20.5 20.6 20.7 20.8 20.9 20.10 20.11 20.12 21 What is an annotation? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The server prefix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Frames . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Displays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Annotation for GDB input . . . . . . . . . . . . . . . . . . . . . . . . . . . . Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Information on breakpoints . . . . . . . . . . . . . . . . . . . . . . . . . . . Invalidation notices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Running the program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Displaying source . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Annotations We Might Want in the Future . . . . . . . . . . . . 243 243 244 245 246 247 247 248 248 249 249 250 The gdb/mi Interface . . . . . . . . . . . . . . . . . . . 251 Function and purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Notation and terminology . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1 gdb/mi Command Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.1.1 gdb/mi Input syntax . . . . . . . . . . . . . . . . . . . . . . . . 21.1.2 gdb/mi Output syntax . . . . . . . . . . . . . . . . . . . . . . 21.1.3 Simple examples of gdb/mi interaction . . . . . . . . 21.2 gdb/mi compatibility with CLI . . . . . . . . . . . . . . . . . . . . . . . 21.3 gdb/mi output records . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3.1 gdb/mi result records . . . . . . . . . . . . . . . . . . . . . . . 21.3.2 gdb/mi stream records . . . . . . . . . . . . . . . . . . . . . . 21.3.3 gdb/mi out-of-band records . . . . . . . . . . . . . . . . . . 21.4 gdb/mi command description format . . . . . . . . . . . . . . . . . . 21.5 gdb/mi breakpoint table commands . . . . . . . . . . . . . . . . . . . 21.6 gdb/mi Data manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.7 gdb/mi program control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 251 251 251 252 254 254 255 255 255 255 256 257 265 275 x Debugging with GDB 21.8 21.9 21.10 21.11 21.12 21.13 21.14 22 Miscellaneous GDB commands in gdb/mi. . . . . . . . . . . . . . gdb/mi Stack Manipulation Commands . . . . . . . . . . . . . . . gdb/mi Symbol query commands . . . . . . . . . . . . . . . . . . . . gdb/mi Target Manipulation Commands . . . . . . . . . . . . . gdb/mi thread commands . . . . . . . . . . . . . . . . . . . . . . . . . . . gdb/mi tracepoint commands . . . . . . . . . . . . . . . . . . . . . . . . gdb/mi variable objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 288 293 296 301 303 303 Reporting Bugs in GDB . . . . . . . . . . . . . . . . 309 22.1 Have you found a bug? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 22.2 How to report bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309 Appendix A Installing GDB . . . . . . . . . . . . . . . . 313 A.1 Compiling GDB in another directory . . . . . . . . . . . . . . . . . . . 314 A.2 Specifying names for hosts and targets . . . . . . . . . . . . . . . . . 315 A.3 configure options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 316 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319

64,637

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧