User ManualTable of ContentsDebugging with GDB Manual1Table of Contents3Summary of GDB15Free Software15Contributors to GDB151 A Sample GDB Session191.1 Loading the Executable191.2 Setting Display width201.3 Setting Breakpoints201.4 Running the executable under GDB201.5 Stepping to the next line in the source program201.6 Stepping into a subroutine211.7 Examining the Stack211.8 Printing Variable Values211.9 Listing Source Code221.10 Setting Variable Values During a Session222 Getting In and Out of GDB252.1 Invoking GDB252.1.1 Choosing files262.1.2 Choosing modes272.1.3 Redirecting WDB input and output to a file302.2 Quitting GDB302.3 Shell commands313 GDB Commands333.1 Command syntax333.2 Command completion333.3 Getting help354 Running Programs Under GDB394.1 Compiling for debugging394.2 Starting your program394.3 Arguments To Your Program414.4 Program Environment414.5 Working directory434.6 Program Input and Output434.7 Debugging a Running Process444.8 Killing the child process454.9 Debugging programs with multiple threads464.10 Debugging programs with multiple processes495 Stopping and Continuing515.1 Breakpoints515.1.1 Setting breakpoints525.1.2 Setting catchpoints565.1.3 Deleting breakpoints585.1.4 Disabling breakpoints585.1.5 Break conditions595.1.6 Breakpoint command lists615.1.7 Breakpoint menus625.1.8 “Cannot insert breakpoints”635.2 Continuing and stepping645.3 Signals675.4 Stopping and starting multi-thread programs696 Examining the Stack716.1 Stack frames716.2 Stacks Without frames726.3 Commands for Examining the Stack726.4 Backtraces726.5 Selecting a frame736.6 Information about a frame747 Examining Source Files777.1 Printing source lines777.2 Searching source files787.3 Specifying source directories797.4 Source and machine code808 Examining Data838.1 Expressions838.2 Program variables848.3 Artificial arrays858.4 Output formats868.5 Examining memory878.6 Automatic display898.7 Print settings908.8 Value history958.9 Convenience variables968.10 Registers988.11 Printing Floating Point Values998.12 Floating point hardware999 Using GDB with Different Languages1019.1 Switching between source languages1019.1.1 List of filename extensions and languages1019.1.2 Setting the working language1029.1.3 Having GDB infer the source language1029.2 Displaying the language1039.3 Type and range checking1039.3.1 An overview of type checking1039.3.2 An overview of range checking1049.4 Supported languages1059.4.1 C and C++1069.4.1.1 C and C++ operators1069.4.1.2 C and C++ constants1089.4.1.3 C++ expressions1099.4.1.4 C and C++ defaults1109.4.1.5 C and C++ type and range checks1109.4.1.6 GDB and C1119.4.1.7 GDB features for C++1119.4.2 Fortran1129.4.2.1 Fortran types1129.4.2.2 Fortran operators1139.4.2.3 Fortran special issues11410 Examining the Symbol Table11511 Altering Execution11911.1 Assignment to variables11911.2 Continuing at a different address12011.3 Giving your program a signal12111.4 Returning from a function12111.5 Calling program functions12211.6 Patching programs12212 GDB Files12512.1 Commands to specify files12512.2 Specifying shared library locations13012.3 Errors reading symbol files13113 Specifying a Debugging Target13313.1 Active targets13313.2 Commands for managing targets13313.3 Choosing target byte order13514 HP-UX Configuration-Specific Information13714.1 Summary of HP Enhancements to GDB13714.2 HP-UX dependencies14014.2.1 Linker Dependencies14014.2.2 Dependent Standard Library Routines for Run Time Checking14014.3 Supported Platforms and Modes14214.4 HP-UX targets14314.5 Support for Alternate root14314.6 Specifying object file directories14414.7 Fix and continue debugging14514.7.1 Fix and Continue compiler dependencies14614.7.2 Fix and Continue restrictions14614.7.3 Using Fix and Continue14714.7.4 Example Fix and Continue session14814.8 Inline Support15014.8.1 Inline Debugging in HP 9000 Systems15014.8.2 Inline Debugging in Integrity Systems15114.8.2.1 Debugging Inline Functions in Integrity Systems15214.9 Debugging Macros15314.9.1 Viewing and Evaluating Macro Definitions15314.9.1.1 Compiler Options to Enable Macro Debugging15414.9.2 Examples for Macro Debugging15514.10 Debugging Memory Problems15714.10.1 When to suspect a memory leak15814.10.2 Memory debugging restrictions15814.10.3 Memory Debugging Methodologies15814.10.4 Debugging Memory in Interactive Mode15914.10.4.1 Commands for interactive memory debugging15914.10.4.2 Example for interactive debugging session16314.10.5 Debugging Memory in Batch Mode16414.10.5.1 Setting Configuration Options for Batch Mode16414.10.5.2 Environment variable setting for Batch mode debugging16714.10.5.3 Example for Batch Mode RTC16914.10.6 Debugging Memory Interactively After Attaching to a Running Process17114.10.7 Configuring memory debugging settings17314.10.7.1 Specifying the stack depth17314.10.7.2 Specifying minimum leak size17314.10.7.3 Specifying minimum block size17414.10.8 Scenarios in memory debugging17414.10.8.1 Stop when freeing unallocated or deallocated blocks17414.10.8.2 Stop when freeing a block if bad writes occurred outside block boundary17414.10.8.3 Stop when a specified block address is allocated or deallocated17514.10.8.4 Scramble previous memory contents at malloc/free calls17514.10.8.5 Detect dangling pointers and dangling blocks17514.10.8.6 Detect in-block corruption of freed blocks17614.10.8.7 Specify the amount of guard bytes for every block of allocated memory17614.10.9 Comparison of Memory Debugging Commands in Interactive Mode and Batch Mode17614.10.10 Heap Profiling17814.10.10.1 Commands for heap profiling17814.10.10.2 info heap arena17914.10.10.3 info heap arena [0 |1|2|..] blocks stacks17914.10.10.4 info module ADDRESS17914.10.10.5 info heap process17914.10.10.6 Example for heap profiling17914.10.11 Memory Checking Analysis for User Defined Memory Management Routines18014.10.12 Commands to track the change in data segment value18014.11 Thread Debugging Support18114.11.1 Support for Enabling and Disabling Specific Threads18114.11.2 Backtrace Support for Thread Debugging18214.11.3 Advanced Thread Debugging Support18214.11.3.1 Pre-requisites for Advanced Thread Debugging18314.11.3.2 Enabling and Disabling Advanced Thread Debugging Features18314.11.3.3 Commands to view information on pthread primitives18714.11.4 Debugging Threads Interactively After Attaching to a Process18714.11.5 Thread Debugging in Batch Mode18914.11.5.1 Pre-requisites for Batch mode of Thread Debugging19014.11.5.2 Limitations in Batch mode of thread debugging19314.11.6 Thread Debugging in +check Mode19314.11.7 Known issues with Thread Debugging for Interactive and Batch mode19414.12 Debugging MPI Programs19414.13 Debugging multiple processes ( programs with fork and vfork calls)19514.13.1 Ask mode for set follow-fork-mode19514.13.2 Serial mode for set follow-fork-mode19514.13.3 Support for showing unwind info19514.13.4 Printing CFM and PFS registers19614.14 Command to Search for a Pattern in the Memory Address Space19614.15 Debugging Core Files20014.15.1 Generating core files with packcore /unpackcore/getcore20014.15.2 Support for the info target Command20114.15.3 Support for the dumpcore command20214.15.3.1 Enhancements to the dumpcore command20214.15.4 Support for display of run time type information20314.16 Printing the Execution Path Entries for the Current Frame or Thread20314.16.1 Compiler Dependencies for Printing the Execution Path Entries20414.16.2 Example Illustrating Execution Path Recovery20514.17 Command to Unwind Beyond 10000 Frames20614.18 Invoking GDB Before a Program Aborts20714.19 Aborting a Command Line Call20714.20 Instruction Level Stepping20814.21 Enhanced support for watchpoints and breakpoints20814.21.1 Deferred watchpoints20814.21.2 Hardware watchpoints20814.21.3 Hardware breakpoints20814.21.3.1 Setting breakpoints in unstripped shared library20914.21.4 Support for procedural breakpoints20914.21.5 Support for template breakpoints20914.22 Debugging support for shared libraries21014.22.1 Using shared library as main program21014.22.2 Setting Deferred Breakpoints in Shared Library21114.22.3 Using catch load21114.22.4 Privately mapping shared libraries21114.22.5 Selectively Mapping Shared Libraries As Private21214.22.6 Setting breakpoints in shared library21314.22.7 Enhancement to the info shared Command21314.23 Debugging support for Decimal Floating Point data type21314.23.1 Printing Decimal Floating point data types21314.23.1.1 Printing Decimal floating point constant21414.23.1.2 Printing Decimal floating point variable21414.23.2 Printing NaT Registers21414.23.3 Handling Decimal Floating Point Data types21414.23.4 Evaluating Decimal Floating Point data types21414.23.4.1 Printing type of Decimal Floating Point variable21514.24 Additional Support for binary floating point data type21614.24.1 Support for Binary Floating Point constants f, l21614.24.2 Support Binary Floating Point variables with format specifier21614.25 Language support21714.25.1 Enhanced Java Debugging Support21714.25.1.1 Java Stack Unwind Features21714.25.1.2 gdb Subcommands for Java VM Debugging21814.25.1.3 Java corefile debugging support22014.25.1.4 Java attach mode debugging support22014.25.2 Enhanced support for C++ templates22114.25.3 Support for _ _fpreg data type on IPF22214.25.4 Support for _Complex variables in HP C22214.25.5 Support for debugging namespaces22214.25.6 Command for evaluating the address of an expression22314.26 Viewing Wide Character Strings22314.27 Support for output logging22414.27.1 Support for dumping array in an ASCII file22414.27.2 Support for Fortran array slices22514.27.3 Displaying enumerators22514.27.4 Support for debugging typedefs22514.27.5 Support for steplast command for C and C++22514.28 Getting information from a non-debug executable22614.29 Debugging optimized code22714.29.1 Debugging Optimized Code at Various Optimization Levels22914.29.1.1 +O0 and +O122914.29.1.2 +O2/+O3/+O4/-ipo22914.30 Debugging with ARIES23014.30.1 Debugging the application using GDB under ARIES23114.30.1.1 Limitations of GDB Support under ARIES23114.30.2 Attaching GDB to an already running emulated process23214.30.3 Detecting memory leaks using GDB under ARIES23214.31 Visual Interface for WDB23314.31.1 Starting and stopping Visual Interface for WDB23314.31.2 Navigating the Visual Interface for WDB display23414.31.3 Specifying foreground and background colors23514.31.4 Using the X-window graphical interface23514.31.5 Using the TUI mode23614.31.6 Changing the size of the source or debugger pane23614.31.7 Using commands to browse through source files23714.31.8 Loading source files23714.31.9 Editing source files23714.31.10 Editing the command line and command-line history23714.31.11 Saving the contents of a debugging session to a file23714.32 Support for ddd23814.33 Support for XDB commands23814.33.1 stop in/at dbx commands23814.34 GNU GDB Logging Commands23814.35 Support for command line calls in a stripped executable23814.35.1 Support for command line calls in a stripped executable on PA-RISC systems23914.35.2 Additional support for command line calls in a stripped executable23914.35.2.1 For 32-bit applications:23914.35.2.2 For 64-bit applications24014.35.3 Support for debugging stripped binaries24014.35.3.1 Printing of locals and globals in a stripped module24014.35.3.2 Backtrace on stripped frames24014.35.3.3 Command line calls to non-stripped library24014.35.3.4 Setting breakpoints in unstripped shared library24014.36 Displaying the current block scope information24114.37 Linux support24115 The HP-UX Terminal User Interface24315.1 Starting the TUI24315.2 Automatically running a program at startup24415.3 Screen Layouts24415.3.1 Source pane24515.3.2 Disassembly pane24515.3.3 Source/Disassembly pane24615.3.4 Disassembly/Register pane24615.3.5 Source/Register pane24715.4 Cycling through the panes24815.5 Changing pane focus24815.6 Scrolling panes25015.7 Changing the register display25015.8 Changing the pane size25115.9 Refreshing and updating the window25216 XDB to WDB Transition Guide25316.1 By-function lists of XDB commands and HP WDB equivalents25316.1.1 Invocation commands25416.1.2 Window mode commands25416.1.3 File viewing commands25516.1.4 Source directory mapping commands25616.1.5 Data Viewing and modification commands25616.1.6 Stack viewing commands25816.1.7 Status-viewing command25916.1.8 Job control commands25916.2 Overall breakpoint commands26016.2.1 Auxiliary breakpoint commands26016.2.2 Breakpoint creation commands26116.2.3 Breakpoint status commands26216.2.4 All-procedures breakpoint commands26316.2.5 Global breakpoint commands26316.2.6 Assertion control commands26416.2.7 Record and playback commands26416.2.8 Macro facility commands26416.2.9 Signal control commands26516.2.10 Miscellaneous commands26516.3 XDB data formats and HP WDB equivalents26616.4 XDB location syntax and HP WDB equivalents26816.5 XDB special language operators and HP WDB equivalents26816.6 XDB special variables and HP WDB equivalents26916.7 XDB variable identifiers and HP WDB equivalents27016.8 Alphabetical lists of XDB commands and HP WDB equivalents27016.8.1 A27016.8.2 B27116.8.3 C through D27216.8.4 F through K27316.8.5 L27316.8.6 M through P27416.8.7 Q through S27516.8.8 T27516.8.9 U through Z27616.8.10 Symbols27717 Controlling GDB28117.1 Setting the GDB Prompt28117.2 Setting Command Editing Options in GDB28117.3 Setting Command History Feature in GDB28117.4 Setting the GDB Screen Size28317.5 Supported Number Formats28317.6 Optional warnings and messages28417.7 Optional messages about internal happenings28518 Canned Sequences of Commands28718.1 User-defined commands28718.2 User-defined command hooks28818.3 Command files28918.4 Commands for controlled output29019 Using GDB under gnu Emacs29320 GDB Annotations29720.1 What is an annotation?29720.2 The server prefix29720.3 Values29820.4 Frames29920.5 Displays30120.6 Annotation for GDB input30120.7 Errors30220.8 Information on breakpoints30220.9 Invalidation notices30320.10 Running the program30320.11 Displaying source30420.12 Annotations We Might Want in the Future30521 The GDB/MI Interface30721.1 GDB/MI Command Syntax30721.1.1 GDB/MI Input syntax30721.1.2 GDB/MI Output syntax30821.1.3 Simple examples of GDB/MI interaction31021.2 GDB/MI compatibility with CLI31021.3 GDB/MI output records31121.3.1 GDB/MI result records31121.3.2 GDB/MI stream records31121.3.3 GDB/MI out-of-band records31121.4 GDB/MI command description format31121.5 GDB/MI breakpoint table commands31221.6 GDB/MI Data manipulation32021.7 GDB/MI program control33021.8 Miscellaneous GDB commands in GDB/MI33921.9 GDB/MI Stack Manipulation Commands34121.10 GDB/MI Symbol query commands34621.11 GDB/MI Target Manipulation Commands34921.12 GDB/MI thread commands35321.13 GDB/MI tracepoint commands35521.14 GDB/MI variable objects35522 Reporting Bugs in GDB36122.1 Have you found a bug?36122.2 How to report bugs361A Installing GDB365A.1 Compiling GDB in another directory366A.2 Specifying names for hosts and targets367A.3 configure options368Size: 1.99 MBPages: 369Language: EnglishOpen manual