Red Hat ENTERPRISE LINUX 3 - DEBUGGING WITH GDB Manual

Debugging with gdb
Hide thumbs Also See for ENTERPRISE LINUX 3 - DEBUGGING WITH GDB:
Table of Contents

Advertisement

Red Hat Enterprise Linux 3
Debugging with gdb

Advertisement

Table of Contents
loading

Summary of Contents for Red Hat ENTERPRISE LINUX 3 - DEBUGGING WITH GDB

  • Page 1 Red Hat Enterprise Linux 3 Debugging with gdb...
  • Page 2 HTML, PDF, and RPM versions of the manuals are available on the Documentation CD and online at http://www.redhat.com/docs/. The GPG fingerprint of the security@redhat.com key is: CA 20 86 86 2B D6 9D FC 65 F6 EC C4 21 91 80 CD DB 42 A6 0E...
  • Page 3: Table Of Contents

    Table of Contents 1. Debugging with gdb ........................1 2. Summary of gdb..........................3 2.1. Free software........................3 2.2. Free Software Needs Free Documentation ................ 3 2.3. Contributors to gdb ......................4 3. A Sample gdb Session ........................7 4. Getting In and Out of gdb ......................11 4.1.
  • Page 4 9. Examining Source Files ........................ 59 9.1. Printing source lines......................59 9.2. Editing source files......................60 9.2.1. Choosing your editor..................61 9.3. Searching source files ...................... 61 9.4. Specifying source directories................... 62 9.5. Source and machine code....................63 10. Examining Data........................... 65 10.1.
  • Page 5 14.4.1. C and C++ ....................113 14.4.2. Objective-C ....................119 14.4.3. Modula-2....................... 121 14.5. Unsupported languages....................126 15. Examining the Symbol Table ....................129 16. Altering Execution ........................135 16.1. Assignment to variables ....................135 16.2. Continuing at a different address ................. 136 16.3.
  • Page 6 20.3.14. Zilog Z8000 ....................179 20.4. Architectures ........................ 180 20.4.1. A29K......................180 20.4.2. Alpha......................180 20.4.3. MIPS ......................180 21. Controlling gdb ......................... 181 21.1. Prompt.......................... 181 21.2. Command editing......................181 21.3. Command history......................181 21.4. Screen size ........................183 21.5.
  • Page 7 26.8.9. The Command..............220 -break-watch 26.9. gdb/mi Data Manipulation ................... 223 26.9.1. The Command ............223 -data-disassemble 26.9.2. The Command......... 225 -data-evaluate-expression 26.9.3. The Command ........226 -data-list-changed-registers 26.9.4. The Command......... 227 -data-list-register-names 26.9.5. The Command ........227 -data-list-register-values 26.9.6. The Command ............
  • Page 8 26.13.5. The Command............255 -stack-list-locals 26.13.6. The Command............ 256 -stack-select-frame 26.14. gdb/mi Symbol Query Commands ................256 26.14.1. The Command ..........256 -symbol-info-address 26.14.2. The Command ............257 -symbol-info-file 26.14.3. The Command ..........257 -symbol-info-function 26.14.4. The Command ............258 -symbol-info-line 26.14.5.
  • Page 9 27.8. Information on Breakpoints ..................282 27.9. Invalidation Notices ..................... 283 27.10. Running the Program ....................283 27.11. Displaying Source...................... 284 27.12. Annotations We Might Want in the Future ..............285 28. Reporting Bugs in gdb ......................287 28.1. Have you found a bug? ....................287 28.2.
  • Page 10 D.7.5. Memory transfer..................... 337 D.7.6. The Ctrl-C message..................337 D.7.7. Console I/O ....................337 D.7.8. The isatty(3) call .................... 338 D.7.9. The system(3) call..................338 D.7.10. List of supported calls .................. 338 D.7.11. Protocol specific representation of datatypes..........347 D.7.12. Constants...................... 349 D.7.13.
  • Page 11: Debugging With Gdb

    Chapter 1. Debugging with gdb This file describes gdb, the gnu symbolic debugger. This is the Ninth Edition, for gdb Version 2003-07-22-cvs. Copyright (C) 1988-2003 Free Software Foundation, Inc.
  • Page 12 Chapter 1. Debugging with gdb...
  • Page 13: Summary Of Gdb

    Chapter 2. Summary of gdb The purpose of a debugger such as gdb is to allow you to see what is going on "inside" another program while it executes--or what another program was doing at the moment it crashed. gdb can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act: Start your program, specifying anything that might affect its behavior.
  • Page 14: Contributors To Gdb

    Chapter 2. Summary of gdb That wasn’t the first time this sort of thing happened, and it was far from the last. Many times we have heard a GNU user eagerly describe a manual that he is writing, his intended contribution to the community, only to learn that he had ruined everything by signing a publication contract to make it non-free.
  • Page 15 Chapter 2. Summary of gdb Changes much prior to version 2.0 are lost in the mists of time. Plea: Additions to this section are particularly welcome. If you or your friends (or enemies, to be even- handed) have been unfairly omitted from this list, we would like to add your names! So that they may not regard their many labors as thankless, we particularly thank those who shep- herded gdb through major releases: Andrew Cagney (releases 6.0, 5.3, 5.2, 5.1 and 5.0);...
  • Page 16 Chapter 2. Summary of gdb Matsushita sponsored the support for the MN10200 and MN10300 processors. Fujitsu sponsored the support for SPARClite and FR30 processors. Kung Hsu, Jeff Law, and Rick Sladkey added support for hardware watchpoints. Michael Snyder added support for tracepoints. Stu Grossman wrote gdbserver.
  • Page 17: A Sample Gdb Session

    Chapter 3. A Sample gdb Session You can use this manual at your leisure to read all about gdb. However, a handful of commands are enough to get started using the debugger. This chapter illustrates those commands. One of the preliminary versions of gnu (a generic macro processor) exhibits the following bug: sometimes, when we change its quote strings from the default, the commands used to capture one macro definition within another stop working.
  • Page 18 Chapter 3. A Sample gdb Session (gdb) break m4_changequote Breakpoint 1 at 0x62f4: file builtin.c, line 879. Using the command, we start running under gdb control; as long as control does not reach the subroutine, the program runs as usual: m4_changequote (gdb) run Starting program: /work/Editorial/gdb/gnu/m4/m4...
  • Page 19 Chapter 3. A Sample gdb Session 0x79dc in expand_input () at macro.c:40 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195 We step through a few more lines to see what happens. The first two times, we can use ; the next two times we use to avoid falling into the subroutine.
  • Page 20 Chapter 3. A Sample gdb Session (gdb) p len_rquote $4 = 7 That certainly looks wrong, assuming are meant to be the lengths of len_lquote len_rquote respectively. We can set them to better values using the command, since it can lquote rquote print the value of any expression--and that expression can include subroutine calls and assignments.
  • Page 21: Getting In And Out Of Gdb

    Chapter 4. Getting In and Out of gdb This chapter discusses how to start gdb, and how to get out of it. The essentials are: type to start gdb. • type quit or C-d to exit. • 4.1. Invoking gdb Invoke gdb by running the program .
  • Page 22: Choosing Files

    Chapter 4. Getting In and Out of gdb gdb -silent You can further control how gdb starts up by using command-line options. gdb itself can remind you of the options available. Type gdb -help to display all available options and briefly describe their use ( is a shorter equivalent).
  • Page 23: Choosing Modes

    Chapter 4. Getting In and Out of gdb number -pid number number Connect to process ID , as with the command. If there is no such process, gdb number attach will attempt to open a core file named number -command file file Execute gdb commands from file...
  • Page 24 Chapter 4. Getting In and Out of gdb -quiet -silent "Quiet". Do not print the introductory and copyright messages. These messages are also sup- pressed in batch mode. -batch Run in batch mode. Exit with status after processing all the command files specified with (and all commands from initialization files, if not inhibited with ).
  • Page 25 Chapter 4. Getting In and Out of gdb -async Use the asynchronous event loop for the command-line interface. gdb processes all events, such as user keyboard input, via a special event loop. This allows gdb to accept and process user commands in parallel with the debugged process being run , so you don’t need to wait for control to return to gdb before you type the next command.
  • Page 26: Quitting Gdb

    Chapter 4. Getting In and Out of gdb -version This option causes gdb to print its version number and no-warranty blurb, and exit. 4.2. Quitting gdb quit [ expression To exit gdb, use the command (abbreviated ), or type an end-of-file character (usually quit C-d).
  • Page 27 Chapter 4. Getting In and Out of gdb 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 if you want overwrite set logging on overwrite the logfile instead.
  • Page 28 Chapter 4. Getting In and Out of gdb...
  • Page 29: Gdb Commands

    Chapter 5. gdb Commands You can abbreviate a gdb command to the first few letters of the command name, if that abbreviation is unambiguous; and you can repeat certain gdb commands by typing just [RET]. You can also use the [TAB] key to get gdb to fill out the rest of a word in a command (or to show you the alternatives available, if there is more than one possibility).
  • Page 30 Chapter 5. gdb Commands (gdb) info breakpoints You can either press [RET] at this point, to run the command, or backspace info breakpoints and enter something else, if does not look like the command you expected. (If you breakpoints were sure you wanted in the first place, you might as well just type [RET] info breakpoints immediately after...
  • Page 31: Getting Help

    Chapter 5. gdb Commands In general, gdb can tell that a quote is needed (and inserts it) if you have not yet started typing the argument list when you ask for completion on an overloaded symbol. For more information about overloaded functions, refer to Section 14.4.1.3 C++expressions. You can use the command to disable overload resolution;...
  • Page 32 Chapter 5. gdb Commands help command With a command name as argument, gdb displays a short paragraph on how to use that help command. apropos args command searches through all of the gdb commands, and their documenta- apropos args tion, for the regular expression specified in .
  • Page 33 Chapter 5. gdb Commands Here are three miscellaneous subcommands, all of which are exceptional in lacking correspond- show commands: show version Show what version of gdb is running. You should include this information in gdb bug-reports. If multiple versions of gdb are in use at your site, you may need to determine which version of gdb you are running;...
  • Page 34 Chapter 5. gdb Commands...
  • Page 35: Running Programs Under Gdb

    Chapter 6. Running Programs Under gdb When you run a program under gdb, you must first generate debugging information when you compile You may start gdb with its arguments, if any, in an environment of your choice. If you are doing native debugging, you may redirect your program’s input and output, debug an already running process, or kill a child process.
  • Page 36: Your Program's Arguments

    Chapter 6. Running Programs Under gdb If you are running your program in an execution environment that supports processes, creates an inferior process and makes that process run your program. (In environments without processes, jumps to the start of your program.) The execution of a program is affected by certain information it receives from its superior.
  • Page 37: Your Program's Environment

    Chapter 6. Running Programs Under gdb with no arguments uses the same arguments used by the previous , or those set by the command. args set args Specify the arguments to be used the next time your program is run. If has no argu- set args ments,...
  • Page 38: Your Program's Working Directory

    Chapter 6. Running Programs Under gdb tells the debugged program, when subsequently run, that its user is named . (The spaces around are used for clarity here; they are not actually required.) unset environment varname Remove variable from the environment to be passed to your program. This is different varname from removes the variable from the environment,...
  • Page 39: Debugging An Already-Running Process

    Chapter 6. Running Programs Under gdb tty /dev/ttyb directs that processes started with subsequent commands default to do input and output on the terminal and have that as their controlling terminal. /dev/ttyb An explicit redirection in overrides the command’s effect on the input/output device, but not its effect on the controlling terminal.
  • Page 40: Debugging Programs With Multiple Threads

    Chapter 6. Running Programs Under gdb This command is useful if you wish to debug a core dump instead of a running process. gdb ignores any core dump file while your program is running. On some operating systems, a program cannot be executed outside gdb while you have breakpoints set on it inside gdb.
  • Page 41 Chapter 6. Running Programs Under gdb For debugging purposes, gdb associates its own thread number--always a single integer--with each thread in your program. info threads Display a summary of all threads currently in your program. gdb displays for each thread (in this order): 1.
  • Page 42: Debugging Programs With Multiple Processes

    Chapter 6. Running Programs Under gdb 1 system thread 27905 0x7b003498 in _brk () \ from /usr/lib/libc.2 thread threadno Make thread number the current thread. The command argument is the threadno threadno internal gdb thread number, as shown in the first field of the display.
  • Page 43 Chapter 6. Running Programs Under gdb set follow-fork-mode mode Set the debugger response to a program call of . A call to creates fork vfork fork vfork a new process. The can be: mode parent The original process is debugged after a fork. The child process runs unimpeded. This is the default.
  • Page 44 Chapter 6. Running Programs Under gdb...
  • Page 45: Stopping And Continuing

    Chapter 7. Stopping and Continuing The principal purposes of using a debugger are so that you can stop your program before it terminates; or so that, if your program runs into trouble, you can investigate and find out why. Inside gdb, your program may stop for any of several reasons, such as a signal, a breakpoint, or reaching a new line after a gdb command such as .
  • Page 46: Setting Breakpoints

    Chapter 7. Stopping and Continuing 7.1.1. Setting breakpoints Breakpoints are set with the command (abbreviated ). The debugger convenience variable break records the number of the breakpoint you’ve set most recently; refer to Section 10.9 Conve- $bpnum nience variables, for a discussion of what you can do with convenience variables. You have several ways to say where the breakpoint should go.
  • Page 47 Chapter 7. Stopping and Continuing for one of the possible arguments described above (or no argument) specifying where to break. Refer to Section 7.1.6 Break conditions for more information on breakpoint conditions. tbreak args Set a breakpoint enabled only for one stop. are the same as for the command, and args...
  • Page 48: Setting Watchpoints

    Chapter 7. Stopping and Continuing Disposition Whether the breakpoint is marked to be disabled or deleted when hit. Enabled or Disabled Enabled breakpoints are marked with marks breakpoints that are not enabled. Address Where the breakpoint is in your program, as a memory address. What Where the breakpoint is in the source for your program, as a file and line number.
  • Page 49 Chapter 7. Stopping and Continuing awatch expr Set a watchpoint that will break when is either read or written into by the program. expr info watchpoints This command prints a list of watchpoints, breakpoints, and catchpoints; it is the same as info break gdb sets a hardware watchpoint if possible.
  • Page 50: Setting Catchpoints

    Chapter 7. Stopping and Continuing gdb automatically deletes watchpoints that watch local (automatic) variables, or expressions that in- volve such variables, when they go out of scope, that is, when the execution leaves the block in which these variables were defined. In particular, when the program being debugged terminates, all local variables go out of scope, and so only watchpoints that watch global variables remain set.
  • Page 51: Deleting Breakpoints

    Chapter 7. Stopping and Continuing unload unload libname The unloading of any dynamically loaded shared library, or the unloading of the library . This is currently only available for HP-UX. libname tcatch event Set a catchpoint that is enabled only for one stop. The catchpoint is automatically deleted after the first time the event is caught.
  • Page 52: Disabling Breakpoints

    Chapter 7. Stopping and Continuing It is not necessary to delete a breakpoint to proceed past it. gdb automatically ignores breakpoints on the first instruction to be executed when you continue execution without changing the execution address. clear Delete any breakpoints at the next instruction to be executed in the selected stack frame (refer to Section 8.3 Selecting a frame).
  • Page 53: Break Conditions

    Chapter 7. Stopping and Continuing enable [breakpoints] [ ...] range Enable the specified breakpoints (or all defined breakpoints). They become effective once again in stopping your program. enable [breakpoints] once range Enable the specified breakpoints temporarily. gdb disables any of these breakpoints immediately after stopping your program.
  • Page 54: Breakpoint Command Lists

    Chapter 7. Stopping and Continuing No symbol "foo" in current context. gdb does not actually evaluate at the time the command (or a com- expression condition mand that sets a breakpoint with a condition, like ) is given, however. Refer to break if ...
  • Page 55: Breakpoint Menus

    Chapter 7. Stopping and Continuing You can use breakpoint commands to start your program up again. Simply use the com- continue mand, or , or any other command that resumes execution. step Any other commands in the command list, after a command that resumes execution, are ignored. This is because any time you resume execution (even with a simple ), you may encounter next...
  • Page 56: Cannot Insert Breakpoints

    Chapter 7. Stopping and Continuing [1] all [2] file:String.cc; line number:867 [3] file:String.cc; line number:860 [4] file:String.cc; line number:875 [5] file:String.cc; line number:853 [6] file:String.cc; line number:846 [7] file:String.cc; line number:735 2 4 6 Breakpoint 1 at 0xb26c: file String.cc, line 867. Breakpoint 2 at 0xb344: file String.cc, line 875.
  • Page 57: Continuing And Stepping

    Chapter 7. Stopping and Continuing 7.2. Continuing and stepping Continuing means resuming program execution until your program completes normally. In contrast, stepping means executing just one more "step" of your program, where "step" may mean either one line of source code, or one machine instruction (depending on what particular command you use). Either when continuing or when stepping, your program may stop even sooner, due to a breakpoint or a signal.
  • Page 58 Chapter 7. Stopping and Continuing next [ count Continue to the next source line in the current (innermost) stack frame. This is similar to step but function calls that appear within the line of code are executed without stopping. Execution stops when control reaches a different line of code at the original stack level that was executing when you gave the command.
  • Page 59: Signals

    Chapter 7. Stopping and Continuing written before the body of the loop. The command appeared to step back to the beginning until of the loop when it advanced to this expression; however, it has not really gone to an earlier statement--not in terms of the actual machine code.
  • Page 60 Chapter 7. Stopping and Continuing program gets from referencing a place in memory far away from all the areas in use; occurs SIGALRM when the alarm clock timer goes off (which happens only if your program has requested an alarm). Some signals, including , are a normal part of the functioning of your program.
  • Page 61: Stopping And Starting Multi-Thread Programs

    Chapter 7. Stopping and Continuing nopass ignore {No value for ‘ listitem>GDBN’} should not allow your program to see this signal. nopass are synonyms. ignore When a signal stops your program, the signal is not visible to the program until you continue. Your program sees the signal then, if is in effect for the signal in question at that time.
  • Page 62 Chapter 7. Stopping and Continuing set scheduler-locking mode Set the scheduler locking mode. If it is , then there is no locking and any thread may run at any time. If , then only the current thread may run when the inferior is resumed. The mode step optimizes for single-stepping.
  • Page 63: Examining The Stack

    Chapter 8. Examining the Stack When your program has stopped, the first thing you need to know is where it stopped and how it got there. Each time your program performs a function call, information about the call is generated. That in- formation includes the location of the call in your program, the arguments of the call, and the local variables of the function being called.
  • Page 64: Backtraces

    Chapter 8. Examining the Stack frame args command allows you to move from one stack frame to another, and to print the stack frame frame you select. may be either the address of the frame or the stack frame number. Without args an argument, prints the current stack frame.
  • Page 65: Selecting A Frame

    Chapter 8. Examining the Stack the backtrace, to avoid tracing into highly system-specific (and generally uninteresting) code. If you need to examine the startup code, then you can change this behavior. set backtrace-below-main off Backtraces will stop when they encounter the user entry point. This is the default. set backtrace-below-main set backtrace-below-main on Backtraces will continue past the user entry point to the top of the stack.
  • Page 66: Information About A Frame

    Chapter 8. Examining the Stack For example: (gdb) up 0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc) at env.c:10 read_input_file (argv[i]); After such a printout, the command with no arguments prints ten lines centered on the point list of execution in the frame. You can also edit the program at the point of execution with your favorite editing program by typing .
  • Page 67 Chapter 8. Examining the Stack info frame addr info f addr Print a verbose description of the frame at address , without selecting that frame. The se- addr lected frame remains unchanged by this command. This requires the same kind of address (more than one for some architectures) that you specify in the command.
  • Page 68 Chapter 8. Examining the Stack...
  • Page 69: Examining Source Files

    Chapter 9. Examining Source Files gdb can print parts of your program’s source, since the debugging information recorded in the program tells gdb what source files were used to build it. When your program stops, gdb spontaneously prints the line where it stopped. Likewise, when you select a stack frame (refer to Section 8.3 Selecting a frame), gdb prints the line where execution in that frame has stopped.
  • Page 70: Editing Source Files

    Chapter 9. Examining Source Files list linespec Print lines centered around the line specified by linespec list first last Print lines from . Both arguments are linespecs. first last list , last Print lines ending with last list first Print lines starting with first list + Print lines just after the lines last printed.
  • Page 71: Choosing Your Editor

    Chapter 9. Examining Source Files 9.2. Editing source files To edit the lines in a source file, use the command. The editing program of your choice is edit invoked with the current line set to the active line in the program. Alternatively, there are several ways to specify what part of the file you want to print if you want to see other parts of the program.
  • Page 72: Specifying Source Directories

    Chapter 9. Examining Source Files forward-search regexp search regexp The command checks each line, starting with the one following the forward-search regexp last line listed, for a match for . It lists the line that is found. You can use the synonym regexp or abbreviate the command name as search...
  • Page 73: Source And Machine Code

    Chapter 9. Examining Source Files 9.5. Source and machine code You can use the command to map source lines to program addresses (and vice versa), info line and the command to display a range of addresses as machine instructions. When run disassemble under gnu Emacs mode, the command causes the arrow to point to the line specified.
  • Page 74 Chapter 9. Examining Source Files set disassembly-flavor instruction-set Select the instruction set to use when disassembling the program via the disassemble commands. Currently this command is only defined for the Intel x86 family. You can set instruction-set to either . The default is , the AT&T flavor used by default by Unix assemblers intel for x86-based targets.
  • Page 75: Examining Data

    Chapter 10. Examining Data The usual way to examine data in your program is with the command (abbreviated ), or its print synonym . It evaluates and prints the value of an expression of the language your program is inspect written in (refer to Chapter 14 Using gdb with Different Languages).
  • Page 76: Program Variables

    Chapter 10. Examining Data allows you to specify a variable in terms of the file or function where it is defined. Refer to Section 10.2 Program variables. type addr Refers to an object of type stored at address in memory. may be any expression type addr...
  • Page 77: Artificial Arrays

    Chapter 10. Examining Data (gdb) p ’f2.c’::x This use of is very rarely in conflict with the very similar use of the same notation in C++. gdb also supports use of the C++ scope resolution operator in gdb expressions. Warning: Occasionally, a local variable may appear to have the wrong value at certain points in a function- -just after entry to a new scope, and just before exit.
  • Page 78: Output Formats

    Chapter 10. Examining Data The left operand of must reside in memory. Array values made with in this way behave just like other arrays in terms of subscripting, and are coerced to pointers when used in expressions. Artificial arrays most often appear in expressions via the value history (refer to Section 10.8 Value history), after printing one out.
  • Page 79: Examining Memory

    Chapter 10. Examining Data Print as integer in octal. Print as integer in binary. The letter stands for "two". Print as an address, both absolute in hexadecimal and as an offset from the nearest preceding symbol. You can use this format used to discover where (in what function) an unknown address is located: (gdb) p/a 0x54320 $3 = 0x54320...
  • Page 80 Chapter 10. Examining Data , the repeat count The repeat count is a decimal integer; the default is 1. It specifies how much memory (counting by units ) to display. , the display format The display format is one of the formats used by (null-terminated string), or (machine print...
  • Page 81: Automatic Display

    Chapter 10. Examining Data The addresses and contents printed by the command are not saved in the value history because there is often too much of them and they would get in the way. Instead, gdb makes these values available for subsequent use in expressions as values of the convenience variables .
  • Page 82: Print Settings

    Chapter 10. Examining Data disable display dnums Disable the display of item numbers . A disabled display item is not printed automatically, dnums but is not forgotten. It may be enabled again later. enable display dnums Enable display of item numbers .
  • Page 83 Chapter 10. Examining Data You can use to eliminate all machine dependent displays from the set print address off gdb interface. For example, with , you should get the same text for back- print address off traces on all machines--whether or not they involve pointer arguments. show print address Show whether or not addresses are to be printed.
  • Page 84 Chapter 10. Examining Data Other settings control how different kinds of objects are printed: set print array set print array on Pretty print arrays. This format is more convenient to read, but uses more space. The default is off. set print array off Return to compressed format for arrays.
  • Page 85 Chapter 10. Examining Data set print sevenbit-strings on Print using only seven-bit characters; if this option is set, gdb displays any eight-bit characters (in strings or character values) using the notation . This setting is best if you are working in \nnn English (ascii) and you use the high-order bit of characters as a marker or "meta"...
  • Page 86 Chapter 10. Examining Data show print demangle Show whether C++ names are printed in mangled or demangled form. set print asm-demangle set print asm-demangle on Print C++ names in their source form rather than their mangled form, even in assembler code printouts such as instruction disassemblies.
  • Page 87: Value History

    Chapter 10. Examining Data set print static-members set print static-members on Print static members when displaying a C++ object. The default is on. set print static-members off Do not print static members when displaying a C++ object. show print static-members Show whether C++ static members are printed, or not.
  • Page 88: Convenience Variables

    Chapter 10. Examining Data Note that the history records values, not expressions. If the value of is 4 and you type these com- mands: print x set x=5 then the value recorded in the value history by the command remains 4 even though the value print has changed.
  • Page 89: Registers

    Chapter 10. Examining Data show convenience Print a list of convenience variables used so far, and their values. Abbreviated show conv One of the ways to use a convenience variable is as a counter to be incremented or a pointer to be advanced.
  • Page 90: Floating Point Hardware

    Chapter 10. Examining Data gdb has four "standard" register names that are available (in expressions) on most machines--whenever they do not conflict with an architecture’s canonical mnemonics for registers. The register names are used for the program counter register and the stack pointer. is used for a register that contains a pointer to the current stack frame, and is used for a register that contains the processor...
  • Page 91: Vector Unit

    Chapter 10. Examining Data 10.11. Floating point hardware Depending on the configuration, gdb may be able to give you more information about the status of the floating point hardware. info float Display hardware-dependent information about the floating point unit. The exact contents and layout vary depending on the floating point chip.
  • Page 92: Attributes

    Chapter 10. Examining Data info mem Print a table of all defined memory regions, with the following columns for each region. Memory Region Number Enabled or Disabled. Enabled memory regions are marked with . Disabled memory regions are marked with Lo Address The address defining the inclusive lower bound of the memory region.
  • Page 93: Copy Between Memory And A File

    Chapter 10. Examining Data Use 64 bit memory accesses. 10.13.1.3. Data Cache The data cache attributes set whether gdb will cache target memory. While this generally improves performance by reducing debug protocol overhead, it can lead to incorrect results because gdb does not know about volatile variables or memory mapped device registers.
  • Page 94: Character Sets

    Chapter 10. Examining Data append [binary] memory filename start_addr end_addr append [binary] value filename expr Append the contents of memory from , or the value of , to start_addr end_addr expr , in raw binary form. (gdb can only append data to files in raw binary form.) filename restore [binary]...
  • Page 95 Chapter 10. Examining Data show charset Show the names of the current host and target charsets. show host-charset Show the name of the current host charset. show target-charset Show the name of the current target charset. gdb currently includes support for the following character sets: ASCII Seven-bit U.S.
  • Page 96 Chapter 10. Examining Data We can use the command to see what character sets gdb is currently using to interpret show charset and display characters and strings: (gdb) show charset The current host and target character set is ‘ISO-8859-1’. (gdb) For the sake of printing this manual, let’s use ascii as our initial character set: (gdb) set charset ASCII (gdb) show charset...
  • Page 97 Chapter 10. Examining Data We can select ibm1047 as our target character set, and examine the program’s strings again. Now the ascii string is wrong, but gdb translates the contents of from the target character set, ibm1047_hello ibm1047, to the host character set, ascii, and they display correctly: (gdb) set target-charset IBM1047 (gdb) show charset The current host character set is ‘ASCII’.
  • Page 98 Chapter 10. Examining Data...
  • Page 99: C Preprocessor Macros

    Chapter 11. C Preprocessor Macros Some languages, such as C and C++, provide a way to define and invoke "preprocessor macros" which expand into strings of tokens. gdb can evaluate expressions containing macro invocations, show the result of macro expansion, and show a macro’s definition, including where it was defined. You may need to compile your program specially to provide gdb with information about preproces- sor macros.
  • Page 100 Chapter 11. C Preprocessor Macros definitions for present in the program being debugged, as well as any previous user- macro supplied definition. macro undef macro (This command is not yet implemented.) Remove any user-supplied definition for the macro named . This command only affects definitions provided with the com- macro macro define...
  • Page 101 Chapter 11. C Preprocessor Macros #define N 28 printf ("Hello, world!\n"); #undef N printf ("We’re so creative.\n"); (gdb) info macro ADD Defined at /home/jimb/gdb/macros/play/sample.c:5 #define ADD(x) (M + x) (gdb) info macro Q Defined at /home/jimb/gdb/macros/play/sample.h:1 included at /home/jimb/gdb/macros/play/sample.c:2 #define Q (gdb) macro expand ADD(1) expands to: (42 + 1) (gdb) macro expand-once ADD(1)
  • Page 102 Chapter 11. C Preprocessor Macros We’re so creative. printf ("Goodbye, world!\n"); (gdb) info macro N Defined at /home/jimb/gdb/macros/play/sample.c:13 #define N 1729 (gdb) macro expand N Q M expands to: 1729 (gdb) print N Q M $2 = 0 (gdb)
  • Page 103: Tracepoints

    Chapter 12. Tracepoints In some applications, it is not feasible for the debugger to interrupt the program’s execution long enough for the developer to learn anything helpful about its behavior. If the program’s correctness depends on its real-time behavior, delays introduced by a debugger might cause the program to change its behavior drastically, or perhaps fail, even when the code itself is correct.
  • Page 104: Enable And Disable Tracepoints

    Chapter 12. Tracepoints (gdb) trace my_function // first source line of function (gdb) trace *my_function // EXACT start address of function (gdb) trace *0x2117c4 // an address You can abbreviate trace The convenience variable records the tracepoint number of the most recently set trace- $tpnum point.
  • Page 105: Tracepoint Action Lists

    Chapter 12. Tracepoints (gdb) pass 1 // Stop tracing when foo has been // executed 3 times OR when bar has // been executed 2 times // OR when baz has been executed 1 time. 12.1.4. Tracepoint Action Lists actions [ This command will prompt for a list of actions to be taken when the tracepoint is hit.
  • Page 106: Listing Tracepoints

    Chapter 12. Tracepoints $locals collect all local variables. You can give several consecutive commands, each one with a single argument, or one collect command with several arguments separated by commas: the effect is the same. collect The command (info scope) is particularly useful for figuring out what data to col- info scope lect.
  • Page 107: Starting And Stopping Trace Experiment

    Chapter 12. Tracepoints 12.1.6. Starting and Stopping Trace Experiment tstart This command takes no arguments. It starts the trace experiment, and begins collecting data. This has the side effect of discarding all the data collected in the trace buffer during the previous trace experiment.
  • Page 108 Chapter 12. Tracepoints tfind start Find the first snapshot in the buffer. This is a synonym for (since 0 is the number of the tfind 0 first snapshot). tfind none Stop debugging trace snapshots, resume live debugging. tfind end Same as tfind none tfind No argument means find the next trace snapshot.
  • Page 109: Tdump

    Chapter 12. Tracepoints (gdb) tfind start (gdb) while ($trace_frame != -1) printf "Frame %d, PC = %08X, SP = %08X, FP = %08X\n", \ $trace_frame, $pc, $sp, $fp tfind Frame 0, PC = 0020DC64, SP = 0030BF3C, FP = 0030BF44 Frame 1, PC = 0020DC6C, SP = 0030BF38, FP = 0030BF44 Frame 2, PC = 0020DC70, SP = 0030BF34, FP = 0030BF44 Frame 3, PC = 0020DC74, SP = 0030BF30, FP = 0030BF44...
  • Page 110: Convenience Variables For Tracepoints

    Chapter 12. Tracepoints 0xe0 0x380035 3670069 0x19e24a 1696330 0x3000668 50333288 0x100 0x322000 3284992 0x3000698 50333336 0x1ad3cc 1758156 0x30bf3c 0x30bf3c 0x30bf34 0x30bf34 0x20b2c8 0x20b2c8 fpcontrol fpstatus fpiaddr p = 0x20e5b4 "gdb-test" p1 = (void *) 0x11 p2 = (void *) 0x22 p3 = (void *) 0x33 p4 = (void *) 0x44 p5 = (void *) 0x55...
  • Page 111 Chapter 12. Tracepoints (char []) $trace_func The name of the function containing $tracepoint Note: is not suitable for use in , use instead. $trace_file printf output Here’s a simple example of using these convenience variables for stepping through all the trace snap- shots and printing some of their data.
  • Page 112 Chapter 12. Tracepoints...
  • Page 113: Debugging Programs That Use Overlays

    Chapter 13. Debugging Programs That Use Overlays If your program is too large to fit completely in your target system’s memory, you can sometimes use overlays to work around this problem. gdb provides some support for debugging programs that use overlays.
  • Page 114: Overlay Commands

    Chapter 13. Debugging Programs That Use Overlays except that the program variables and heap would share an address space with the main program and the overlay area. An overlay loaded into instruction memory and ready for use is called a mapped overlay; its mapped address is its address in the instruction memory.
  • Page 115 Chapter 13. Debugging Programs That Use Overlays overlay manual Enable manual overlay debugging. In this mode, gdb relies on you to tell it which overlays are mapped, and which are not, using the overlay map-overlay overlay unmap-overlay commands described below. overlay map-overlay overlay overlay map...
  • Page 116: Automatic Overlay Debugging

    Chapter 13. Debugging Programs That Use Overlays (gdb) overlay list Section .ov.foo.text, loaded at 0x100000 - 0x100034, mapped at 0x1016 - 0x104a (gdb) print foo $6 = {int (int)} 0x1016 When overlay debugging is enabled, gdb can find the correct address for functions and variables in an overlay, whether or not the overlay is mapped.
  • Page 117: Overlay Sample Program

    Chapter 13. Debugging Programs That Use Overlays In addition, your overlay manager may define a function called . If this function _ovly_debug_event is defined, gdb will silently set a breakpoint there. If the overlay manager then calls this function whenever it has changed the overlay table, this will enable gdb to accurately keep track of which overlays are in program memory, and update any breakpoints that may be set in overlays.
  • Page 118 Chapter 13. Debugging Programs That Use Overlays...
  • Page 119: Using Gdb With Different Languages

    Chapter 14. Using gdb with Different Languages Although programming languages generally have common aspects, they are rarely expressed in the same manner. For instance, in ANSI C, dereferencing a pointer is accomplished by , but in Modula-2, it is accomplished by .
  • Page 120: Setting The Working Language

    Chapter 14. Using gdb with Different Languages Fortran source file .mod Modula-2 source file Assembler source file. This actually behaves almost like C, but gdb does not skip over function prologues when stepping. In addition, you may set the language associated with a filename extension. Refer to Section 14.2 Displaying the language.
  • Page 121: Type And Range Checking

    Chapter 14. Using gdb with Different Languages 14.2. Displaying the language The following commands help you find out which language is the working language, and also what language source files were written in. show language Display the current working language. This is the language you can use with commands such as to build and compute expressions that may involve variables in your program.
  • Page 122: An Overview Of Range Checking

    Chapter 14. Using gdb with Different Languages error--> 1 + 2.3 The second example fails because the 1 is not type-compatible with the 2.3. CARDINAL REAL For the expressions you use in gdb commands, you can tell the gdb type checker to skip checking; to treat any mismatches as errors and abandon the expression;...
  • Page 123: Supported Languages

    Chapter 14. Using gdb with Different Languages an error. In many implementations of C, mathematical overflow causes the result to "wrap around" to lower values--for example, if is the largest integer value, and is the smallest, then + 1 => This, too, is specific to individual languages, and in some cases specific to individual compilers or machines.
  • Page 124 Chapter 14. Using gdb with Different Languages For best results when using gnu C++, use the DWARF 2 debugging format; if it doesn’t work on your system, try the stabs+ debugging format. You can select those formats explicitly with the command-line options -gdwarf-2 -gstabs+...
  • Page 125 Chapter 14. Using gdb with Different Languages ==, != Equality and inequality. Defined on scalar types. The value of these expressions is 0 for false and non-zero for true. Less than, greater than, less than or equal, greater than or equal. Defined on scalar types. The value of these expressions is 0 for false and non-zero for true.
  • Page 126 Chapter 14. Using gdb with Different Languages .*, - * Dereferences of pointers to members. Array indexing. is defined as . Same precedence as Function parameter list. Same precedence as C++ scope resolution operator. Defined on , and types. struct union class Doubled colons also represent the gdb scope operator (refer to Section 10.1 Expressions).
  • Page 127 Chapter 14. Using gdb with Different Languages 14.4.1.3. C++expressions gdb expression handling can interpret most C++ expressions. Warning: gdb can only debug C++ code if you use the proper compiler and the proper debug format. Currently, gdb works best when debugging C++ code that is compiled with gcc 2.95.3 or with gcc 3.1 or newer, using the options .
  • Page 128 Chapter 14. Using gdb with Different Languages 14.4.1.4. C and C++defaults If you allow gdb to set type and range checking automatically, they both default to whenever the working language changes to C or C++. This happens regardless of whether you or gdb selects the working language.
  • Page 129: Objective-C

    Chapter 14. Using gdb with Different Languages ptype typename Print inheritance relationships as well as other information for type . Refer to Chapter typename 15 Examining the Symbol Table. set print demangle show print demangle set print asm-demangle show print asm-demangle Control whether C++ symbols display in their source form, both when displaying code as C++ source and when displaying disassemblies.
  • Page 130 Chapter 14. Using gdb with Different Languages • clear • break • info line • jump • list A fully qualified Objective-C method name is specified as Class methodName where the minus sign is used to indicate an instance method and a plus sign (not shown) is used to indicate a class method.
  • Page 131: Modula-2

    Chapter 14. Using gdb with Different Languages will tell gdb to send the -hash message to object and print the result. Also an additional command has been added, for short, which is meant to print the description of an object. print-object However, this command may only work with certain Objective-C libraries that have a particular hook function, called...
  • Page 132 Chapter 14. Using gdb with Different Languages Boolean disjunction. Defined on boolean types. AND, & Boolean conjunction. Defined on boolean types. The gdb "artificial array" operator (refer to Section 10.1 Expressions). +, - Addition and subtraction on integral and floating-point types, or union and difference on set types.
  • Page 133 Chapter 14. Using gdb with Different Languages 14.4.3.2. Built-in functions and procedures Modula-2 also makes available several built-in procedures and functions. In describing these, the following metavariables are used: represents an variable. ARRAY represents a constant or variable. CHAR represents a variable or constant of integral type. represents an identifier that belongs to a set.
  • Page 134 Chapter 14. Using gdb with Different Languages EXCL( Removes the element from the set . Returns the new set. FLOAT( Returns the floating point equivalent of the integer HIGH( Returns the index of the last member of INC( Increments the value in the variable by one.
  • Page 135 Chapter 14. Using gdb with Different Languages 14.4.3.3. Constants gdb allows you to express the constants of Modula-2 in the following ways: Integer constants are simply a sequence of digits. When used in an expression, a constant is inter- • preted to be type-compatible with the rest of the expression.
  • Page 136: Unsupported Languages

    Chapter 14. Using gdb with Different Languages 14.4.3.6. Modula-2 type and range checks Warning: in this release, gdb does not yet perform type or range checking. gdb considers two Modula-2 variables type equivalent if: They are of types that have been declared equivalent via a statement •...
  • Page 137 Chapter 14. Using gdb with Different Languages 14.5. Unsupported languages In addition to the other fully-supported programming languages, gdb also provides a pseudo-language, called . It does not represent a real programming language, but provides a set of capabilities minimal close to what the C or assembly languages provide.
  • Page 138 Chapter 14. Using gdb with Different Languages...
  • Page 139: Examining The Symbol Table

    Chapter 15. Examining the Symbol Table The commands described in this chapter allow you to inquire about the symbols (names of variables, functions and types) defined in your program. This information is inherent in the text of your program and does not change as your program executes. gdb finds it in your program’s symbol table, in the file indicated when you started gdb (refer to Section 4.1.1 Choosing files), or by one of the file- management commands (refer to Section 17.1 Commands to specify files).
  • Page 140 Chapter 15. Examining the Symbol Table ptype expr ptype Print a description of the type of expression differs from by printing a expr ptype whatis detailed description, instead of just the name of the type. For example, for this variable declaration: struct complex {double real;...
  • Page 141 Chapter 15. Examining the Symbol Table which programming language it is written in, • whether the executable includes debugging information for that file, and if so, what format the • information is in (e.g., STABS, Dwarf 2, etc.), and whether the debugging information includes information about preprocessor macros. •...
  • Page 142 Chapter 15. Examining the Symbol Table set symbol-reloading off Do not replace symbol definitions when encountering object files of the same name more than once. This is the default state; if you are not running on a system that permits auto- matic relinking of modules, you should leave off, since otherwise gdb symbol-reloading...
  • Page 143 Chapter 15. Examining the Symbol Table text addresses 0x814d3c8 -- 0x8158074 globals (* (struct partial_symbol **) 0x8507a08 @ 9) statics (* (struct partial_symbol **) 0x40e95b78 @ 2882) dependencies (none) (gdb) maint info symtabs (gdb) We see that there is one partial symbol table whose filename contains the string dwarf2read belonging to the executable;...
  • Page 144 Chapter 15. Examining the Symbol Table...
  • Page 145: Altering Execution

    Chapter 16. Altering Execution Once you think you have found an error in your program, you might want to find out for certain whether correcting the apparent error would lead to correct results in the rest of the run. You can find the answer by experiment, using the gdb features for altering execution of the program.
  • Page 146: Continuing At A Different Address

    Chapter 16. Altering Execution $1 = 1 (gdb) set g=4 (gdb) p g $2 = 1 (gdb) r The program being debugged has been started already. Start it from the beginning? (y or n) y Starting program: /home/smith/cc_progs/a.out "/home/smith/cc_progs/a.out": can’t open to read symbols: Invalid bfd target.
  • Page 147: Giving Your Program A Signal

    Chapter 16. Altering Execution jump * address Resume execution at the instruction at address address On many systems, you can get much the same effect as the command by storing a new value jump into the register . The difference is that this does not start your program running; it only changes the address of where it will run when you continue.
  • Page 148: Patching Programs

    Chapter 16. Altering Execution 16.5. Calling program functions call expr Evaluate the expression without displaying returned values. expr void You can use this variant of the command if you want to execute a function from your program, print but without cluttering the output with returned values.
  • Page 149: Gdb Files

    Chapter 17. gdb Files gdb needs to know the file name of the program to be debugged, both in order to read its symbol table and in order to start your program. To debug a core dump of a previous run, you must also tell gdb the name of the core dump file.
  • Page 150 Chapter 17. gdb Files When gdb is configured for a particular environment, it understands debugging information in whatever format is the standard generated for that environment; you may use either a gnu com- piler, or other compilers that adhere to the local conventions. Best results are usually obtained from gnu compilers;...
  • Page 151 Chapter 17. gdb Files add-symbol-file filename address add-symbol-file [ -readnow ] [ -mapped ] filename address add-symbol-file filename section address command reads additional symbol table information from the file add-symbol-file . You would use this command when has been dynamically loaded (by filename filename some other means) into the program that is running.
  • Page 152 Chapter 17. gdb Files currently in use by gdb, and the files from which symbols were loaded. The command help lists all possible targets rather than current ones. target maint info sections Another command that can give you extra information about program sections is maint info .
  • Page 153 Chapter 17. gdb Files NEVER_LOAD An instruction to the linker to not output the section. COFF_SHARED_LIBRARY A notification to the linker that the section contains COFF shared library information. IS_COMMON Section contains common symbols. set trust-readonly-sections on Tell gdb that readonly sections in your object file really are read-only (that is, that their contents will not change).
  • Page 154 Chapter 17. gdb Files sharedlibrary regex share regex Load shared object library symbols for files matching a Unix regular expression. As with files loaded automatically, it only loads shared libraries required by your program for a core file or after typing .
  • Page 155: Debugging Information In Separate Files

    Chapter 17. gdb Files show solib-search-path Display the current shared library search path. 17.2. Debugging Information in Separate Files gdb allows you to put a program’s debugging information in a file separate from the executable itself, in a way that allows gdb to find and load the debugging information automatically. Since debugging information can be very large -- sometimes larger than the executable code itself -- some systems distribute debugging information for their executables in separate files, which users can install only when they need to debug a problem.
  • Page 156 Chapter 17. gdb Files The debugging information file itself should be an ordinary executable, containing a full set of linker symbols, sections, and debugging information. The sections of the debugging information file should have the same names, addresses and sizes as the original file, but they need not contain any data -- much like a section in an ordinary executable.
  • Page 157: Errors Reading Symbol Files

    Chapter 17. gdb Files 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,...
  • Page 158 Chapter 17. gdb Files bad string table offset in symbol Symbol number contains a pointer into the string table which is larger than the size of the string table. gdb circumvents the problem by considering the symbol to have the name , which may cause other problems if many symbols end up with this name.
  • Page 159: Specifying A Debugging Target

    Chapter 18. Specifying a Debugging Target A target is the execution environment occupied by your program. Often, gdb runs in the same host environment as your program; in that case, the debugging target is specified as a side effect when you use the commands.
  • Page 160 Chapter 18. Specifying a Debugging Target set gnutarget args {No value for ‘ listitem>GDBN’} uses its own library BFD to read your files. gdb knows whether it is reading an executable, a core, or a .o file; however, you can specify the file format with the command.
  • Page 161: Choosing Target Byte Order

    Chapter 18. Specifying a Debugging Target load filename Depending on what remote debugging facilities are configured into gdb, the command load may be available. Where it exists, it is meant to make (an executable) available for filename debugging on the remote system--by downloading, or dynamic linking, for example. also load records the...
  • Page 162 Chapter 18. Specifying a Debugging Target 18.5. Kernel Object Display Some targets support kernel object display. Using this facility, gdb communicates specially with the underlying operating system and can display information about operating system-level objects such as mutexes and other synchronization objects. Exactly which objects can be displayed is determined on a per-OS basis.
  • Page 163: Debugging Remote Programs

    Chapter 19. Debugging remote programs 19.1. Connecting to a remote target On the gdb host machine, you will need an unstripped copy of your program, since gdb needs symobl and debugging information. Start up gdb as usual, using the name of the local copy of your program as the first argument.
  • Page 164: Program

    Chapter 19. Debugging remote programs the serial drivers the remote system uses. If you type the interrupt character once again, gdb displays this prompt: Interrupted while waiting for the program. Give up (and stop debugging it)? (y or n) If you type y, gdb abandons the remote debugging session. (If you decide you want to try again later, you can use again to connect once more.) If you type n, gdb goes back to waiting.
  • Page 165: Using The Gdbserve.nlm

    Chapter 19. Debugging remote programs To use a TCP connection instead of a serial line: target gdbserver host:2345 emacs foo.txt The only difference from the previous example is the first argument, specifying that you are communicating with the host gdb via TCP. The argument means that host:2345 gdbserver...
  • Page 166: Implementing A Remote Stub

    Chapter 19. Debugging remote programs 19.4. Remote configuration The following configuration options are available when debugging remote programs: set remote hardware-watchpoint-limit limit set remote hardware-breakpoint-limit limit Restrict gdb to using remote hardware breakpoint or watchpoints. A limit of -1, the de- limit fault, is treated as unlimited.
  • Page 167: What The Stub Can Do For You

    Chapter 19. Debugging remote programs m68k-stub.c For Motorola 680x0 architectures. sh-stub.c For Hitachi SH architectures. sparc-stub.c For sparc architectures. sparcl-stub.c For Fujitsu sparclite architectures. file in the gdb distribution may list other recently added stubs. README 19.5.1. What the stub can do for you The debugging stub for your architecture supplies these three subroutines: set_debug_traps This routine arranges for...
  • Page 168 Chapter 19. Debugging remote programs int getDebugChar() Write this subroutine to read a single character from the serial port. It may be identical to for your target system; a different name is used to allow you to distinguish the two getchar if you wish.
  • Page 169: Putting It All Together

    Chapter 19. Debugging remote programs 19.5.3. Putting it all together In summary, when your program is ready to debug, you must follow these steps. 1. Make sure you have defined the supporting low-level routines (refer to Section 19.5.2 What you must do for the stub): getDebugChar putDebugChar...
  • Page 170 Chapter 19. Debugging remote programs...
  • Page 171: Configuration-Specific Information

    Chapter 20. Configuration-Specific Information While nearly all gdb commands are available for all native and cross versions of the debugger, there are some exceptions. This chapter describes things that are only available in certain configurations. There are three major categories of configurations: native configurations, where the host and target are the same, embedded operating system configurations, which are usually the same for several different processor architectures, and bare embedded processors, which are quite different from each other.
  • Page 172 Chapter 20. Configuration-Specific Information info dos sysinfo This command displays assorted information about the underlying platform: the CPU type and features, the OS version and flavor, the DPMI version, and the available conventional and DPMI memory. info dos gdt info dos ldt info dos idt These 3 commands display entries from, respectively, Global, Local, and Interrupt Descriptor Tables (GDT, LDT, and IDT).
  • Page 173: Features For Debugging Ms Windows Pe Executables

    Chapter 20. Configuration-Specific Information This says that is stored at offset from the page whose physical base address is 0xd30 , and prints all the attributes of that page. 0x02698000 Note that you must cast the addresses of variables to a , since otherwise the value of char * , the base address of all variables and functions in a djgpp program,...
  • Page 174 Chapter 20. Configuration-Specific Information set new-group mode This boolean value controls whether the debuggee should start a new group or stay in the same group as the debugger. This affects the way the Windows OS handles Ctrl-C. show new-group Displays current value of new-group boolean. set debugevents This boolean value adds debug output concerning events seen by the debugger.
  • Page 175 Chapter 20. Configuration-Specific Information of the DLL. Use single-quotes around the name to avoid the exclamation mark ("!") being interpreted as a language operator. Note that the internal name of the DLL may be all upper-case, even though the file name of the DLL is lower-case, or vice-versa.
  • Page 176: Embedded Operating Systems

    Chapter 20. Configuration-Specific Information (gdb) x/2x &’cygwin1!__argv’ 0x610c0aa8 cygwin1!__argv : 0x10021608 0x00000000 (gdb) x/x 0x10021608 0x10021608: 0x0022fd98 (gdb) x/s 0x0022fd98 0x22fd98: "/cygdrive/c/mydirectory/myprogram" Setting a break point within a DLL is possible even before the program starts execution. However, under these circumstances, gdb can’t examine the initial instructions of the function in order to skip the function’s frame set-up code.
  • Page 177 Chapter 20. Configuration-Specific Information To use gdb with VxWorks, you must rebuild your VxWorks kernel to include the remote debugging interface routines in the VxWorks library . To do this, define in the VxWorks rdb.a INCLUDE_RDB configuration file and rebuild your VxWorks kernel. The resulting kernel contains configAll.h , and spawns the source debugging task when VxWorks is booted.
  • Page 178: Embedded Processors

    Chapter 20. Configuration-Specific Information cd " /vw/demo/rdb" vxpath Then, in gdb, type: (vxgdb) cd /vw/demo/rdb hostpath (vxgdb) load prog.o gdb displays a response similar to this: Reading symbol data from wherever/vw/demo/rdb/prog.o... done. You can also use the command to reload an object module after editing and recompiling the load corresponding source file.
  • Page 179: Hitachi H8/300

    Chapter 20. Configuration-Specific Information 20.3.2. Hitachi H8/300 target hms A Hitachi SH, H8/300, or H8/500 board, attached via serial line to your host. Use special com- mands to control the serial line and the communications speed used. device speed target e7000 E7000 emulator for Hitachi H8 and SH.
  • Page 180 Chapter 20. Configuration-Specific Information COM2: 9600, n, 8, 1, p Warning: We have noticed a bug in PC-NFS that conflicts with . If you also run PC-NFS on your asynctsr DOS host, you may need to disable it, or even boot without it, to use to control your development asynctsr board.
  • Page 181: H8/500

    Chapter 20. Configuration-Specific Information target e7000 port speed Use this form if your E7000 is connected to a serial port. The argument identifies what port serial port to use (for example, ). The third argument is the line speed in bits per second (for com2 example, 9600...
  • Page 182: Mips Embedded

    Chapter 20. Configuration-Specific Information target dbug dBUG ROM monitor for Motorola ColdFire. target est EST-300 ICE monitor, running on a CPU32 (M68K) board. target rom68k ROM 68K monitor, running on an M68K IDP board. target rombug ROMBUG ROM monitor for OS/9000. 20.3.6.
  • Page 183: Openrisc 1000

    Chapter 20. Configuration-Specific Information target array Array Tech LSI33K RAID controller board. gdb also supports these special commands for MIPS targets: set processor args show processor Use the command to set the type of MIPS processor when you want to access set processor processor-type-specific registers.
  • Page 184 Chapter 20. Configuration-Specific Information target jtag jtag:// host port Connects to remote JTAG server. JTAG remote server can be either an or1ksim or JTAG server, connected via parallel port to the board. Example: target jtag jtag://localhost:9999 or1ksim command If connected to OpenRISC 1000 Architectural Simulator, proprietary commands can or1ksim be executed.
  • Page 185 Chapter 20. Configuration-Specific Information hwatch conditional Set hardware watchpoint on combination of Load/Store Effecive Address(es) or Data. For exam- ple: hwatch ($LEA == my_var) && ($LDATA 50) || ($SEA == my_var) && ($SDATA = 50) hwatch ($LEA == my_var) && ($LDATA 50) || ($SEA == my_var) &&...
  • Page 186: Powerpc

    Chapter 20. Configuration-Specific Information 20.3.8. PowerPC target dink32 DINK32 ROM monitor. target ppcbug target ppcbug1 PPCBUG ROM monitor for PowerPC. target sds SDS monitor, running on a PowerPC board (such as Motorola’s ADS). 20.3.9. HP PA Embedded target op50n OP50N monitor, running on an OKI HPPA board. target w89k W89K monitor, running on a Winbond HPPA board.
  • Page 187 Chapter 20. Configuration-Specific Information remotetimeout args gdb supports the option . This option is set by the user, and represents the remotetimeout args number of seconds gdb waits for responses. When compiling for debugging, include the options to get debug information and -Ttext relocate the program to where you wish to load it on the target.
  • Page 188: Fujitsu Sparclite

    Chapter 20. Configuration-Specific Information gdb displays messages like these: Connected to ttya. 20.3.11.3. Sparclet download Once connected to the Sparclet target, you can use the gdb command to download the file load from the host to the target. The file name and load offset should be given as arguments to the load command.
  • Page 189: Tandem St2000

    Chapter 20. Configuration-Specific Information 20.3.13. Tandem ST2000 gdb may be used with a Tandem ST2000 phone switch, running Tandem’s STDBUG protocol. To connect your ST2000 to the host system, see the manufacturer’s manual. Once the ST2000 is physically attached, you can run: target st2000 dev speed to establish it as your debugging environment.
  • Page 190: Architectures

    Chapter 20. Configuration-Specific Information time Execution time in 60ths of a second. You can refer to these values in gdb expressions with the usual conventions; for example, b fputc sets a conditional breakpoint that suspends only after at least 5000 simulated if $cycles 5000 clock ticks.
  • Page 191: Controlling Gdb

    Chapter 21. Controlling gdb You can alter the way gdb interacts with you by using the command. For commands controlling how gdb displays data, (refer to Section 10.7 Print settings. Other settings are described here. 21.1. Prompt gdb indicates its readiness to read a command by printing a string called the prompt. This string is normally .
  • Page 192 Chapter 21. Controlling gdb set history filename fname Set the name of the gdb command history file to . This is the file where gdb reads an fname initial command history list, and where it writes the command history from this session when it exits.
  • Page 193: Screen Size

    Chapter 21. Controlling gdb show commands Print ten commands centered on command number show commands + Print ten commands just after the commands last printed. 21.4. Screen size Certain commands to gdb may produce large amounts of information output to the screen. To help you read all of it, gdb pauses and asks you for input at the end of each page of output.
  • Page 194: Configuring The Current Abi

    Chapter 21. Controlling gdb set output-radix base Set the default base for numeric display. Supported choices for are decimal 8, 10, or 16. base must itself be specified either unambiguously or using the current default radix. base show input-radix Display the current default base for numeric input. show output-radix Display the current default base for numeric display.
  • Page 195: Optional Warnings And Messages

    Chapter 21. Controlling gdb "gnu-v2", for versions before 3.0, "gnu-v3", for versions 3.0 and later, and "hpaCC" for the HP ANSI C++ compiler. Other C++ compilers may use the "gnu-v2" or "gnu-v3" ABI’s as well. The default setting is "auto". show cp-abi Show the C++ ABI currently in use.
  • Page 196: Optional Messages About Internal Happenings

    Chapter 21. Controlling gdb If you are willing to unflinchingly face the consequences of your own commands, you can disable this "feature": set confirm off Disables confirmation requests. set confirm on Enables confirmation requests (the default). show confirm Displays state of confirmation requests. 21.8.
  • Page 197 Chapter 21. Controlling gdb set debug remote Turns on or off display of reports on all packets sent back and forth across the serial line to the remote machine. The info is printed on the gdb standard output stream. The default is off. show debug remote Displays the state of display of remote packets.
  • Page 198 Chapter 21. Controlling gdb...
  • Page 199: Canned Sequences Of Commands

    Chapter 22. Canned Sequences of Commands Aside from breakpoint commands (refer to Section 7.1.7 Breakpoint command lists), gdb provides two ways to store sequences of commands for execution as a unit: user-defined commands and command files. 22.1. User-defined commands A user-defined command is a sequence of gdb commands to which you assign a new name as a command.
  • Page 200: User-Defined Command Hooks

    Chapter 22. Canned Sequences of Commands document commandname Document the user-defined command , so that it can be accessed by . The commandname help command must already be defined. This command reads lines of documentation commandname just as reads the lines of the command definition, ending with .
  • Page 201: Command Files

    Chapter 22. Canned Sequences of Commands handle SIGALRM pass define hook-continue handle SIGLARM pass As a further example, to hook at the begining and end of the command, and to add extra text to echo the beginning and end of the message, you could define: define hook-echo echo define hookpost-echo...
  • Page 202: Commands For Controlled Output

    Chapter 22. Canned Sequences of Commands On some configurations of gdb, the init file is known by a different name (these are typically environ- ments where a specialized form of gdb may need to coexist with other forms, hence a different name for the specialized version’s init file).
  • Page 203 Chapter 22. Canned Sequences of Commands echo This is some text\n echo which is continued\n echo onto several lines.\n output expression Print the value of and nothing but that value: no newlines, no . The value is expression not entered in the value history either. Refer to Section 10.1 Expressions, for more information on expressions.
  • Page 204 Chapter 22. Canned Sequences of Commands...
  • Page 205: Command Interpreters

    Chapter 23. Command Interpreters gdb supports multiple command interpreters, and some command infrastructure to allow users or user interface writers to switch between interpreters or run commands in other interpreters. gdb currently supports two command interpreters, the console interpreter (sometimes called the command-line interpreter or cli) and the machine interface interpreter (or gdb/mi).
  • Page 206 Chapter 23. Command Interpreters...
  • Page 207: Gdb Text User Interface

    Chapter 24. gdb Text User Interface The gdb Text User Interface, TUI in short, is a terminal interface which uses the library to curses show the source file, the assembly output, the program registers and gdb commands in separate text windows.
  • Page 208: Tui Key Bindings

    Chapter 24. gdb Text User Interface Hardware breakpoint which was never hit. The second marker indicates whether the breakpoint is enabled or not: Breakpoint is enabled. Breakpoint is disabled. The source, assembly and register windows are attached to the thread and the frame position. They are updated when the current thread changes, when the frame changes or when the program counter changes.
  • Page 209 Chapter 24. gdb Text User Interface C-x C-a C-x a C-x A Enter or leave the TUI mode. When the TUI mode is left, the curses window management is left and gdb operates using its standard mode writing on the terminal directly. When the TUI mode is entered, the control is given back to the curses windows.
  • Page 210: Tui Single Key Mode

    Chapter 24. gdb Text User Interface [C-L] Refresh the screen. In the TUI mode, the arrow keys are used by the active window for scrolling. This means they are not available for readline. It is necessary to use other readline key bindings such as [C-p], [C-n], [C-b] and [C-f].
  • Page 211: Tui Configuration Variables

    Chapter 24. gdb Text User Interface 24.4. TUI specific commands The TUI has specific commands to control the text windows. These commands are always available, that is they do not depend on the current terminal mode in which gdb runs. When gdb is in the standard mode, using these commands will automatically switch in the TUI mode.
  • Page 212 Chapter 24. gdb Text User Interface space Use a space character to draw the border. ascii Use ascii characters + - and | to draw the border. Use the Alternate Character Set to draw the border. The border is drawn using character line graphics if the terminal supports them.
  • Page 213: Using Gdb Under Gnu Emacs

    Chapter 25. Using gdb under gnu Emacs A special interface allows you to use gnu Emacs to view (and edit) the source files for the program you are debugging with gdb. To use this interface, use the command M-x gdb in Emacs. Give the executable file you want to debug as an argument.
  • Page 214 Chapter 25. Using gdb under gnu Emacs C-h m Describe the features of Emacs’ gdb Mode. Execute to another source line, like the gdb command; also update the display window to step show the current file and location. Execute to next source line in this function, skipping all function calls, like the gdb com- next mand.
  • Page 215 Chapter 25. Using gdb under gnu Emacs The source files displayed in Emacs are in ordinary Emacs buffers which are visiting the source files in the usual way. You can edit the files with these buffers if you wish; but keep in mind that gdb communicates with Emacs in terms of line numbers.
  • Page 216 Chapter 25. Using gdb under gnu Emacs...
  • Page 217: The Gdb/Mi Interface

    Chapter 26. The gdb/mi Interface 26.1. Function and Purpose gdb/mi is a line based machine oriented text interface to gdb. It is specifically intended to support the development of systems which use the debugger as just one small component of a larger system. This chapter is a specification of the gdb/mi interface.
  • Page 218: Gdb/Mi Output Syntax

    Chapter 26. The gdb/mi Interface ==> option "-" [ " " parameter parameter ==> parameter non-blank-sequence c-string ==> operation any of the operations described in this chapter ==> non-blank-sequence anything, provided it doesn’t contain special characters such as "-", , """ and of course " " ==>...
  • Page 219 Chapter 26. The gdb/mi Interface ==> async-record exec-async-output status-async-output notify-async-output ==> exec-async-output ] "*" token async-output ==> status-async-output ] "+" token async-output ==> notify-async-output ] "=" token async-output ==> async-output ( "," async-class result ==> result-class "done" | "running" | "connected" | "error" | "exit" ==>...
  • Page 220: Simple Examples Of Gdb/Mi Interaction

    Chapter 26. The gdb/mi Interface ==> log-stream-output "&" c-string ==> CR | CR-LF ==> token any sequence of digits. Notes: All output sequences end in a single line containing a period. • is from the corresponding request. If an execution command is interrupted by the •...
  • Page 221: Gdb/Mi Compatibility With Cli

    Chapter 26. The gdb/mi Interface 26.4.3.2. Simple CLI Command Here’s an example of a simple CLI command being passed through gdb/mi and on to the CLI. print 1+2 - &"print 1+2\n" - ~"$1 = 3\n" - ^done - (gdb) 26.4.3.3. Command With Side Effects -symbol-file xyz.exe - *breakpoint,nr="3",address="0x123",source="a.c:123"...
  • Page 222: Gdb/Mi Stream Records

    Chapter 26. The gdb/mi Interface "^done" [ "," results The synchronous operation was successful, are the return values. results "^running" The asynchronous operation was successfully started. The target is running. "^error" "," c-string The operation failed. The contains the corresponding error message. c-string 26.6.2.
  • Page 223: Motivation

    Chapter 26. The gdb/mi Interface 26.7.1. Motivation The motivation for this collection of commands. 26.7.2. Introduction A brief introduction to this collection of commands as a whole. 26.7.3. Commands For each command in the block, the following is described: 26.7.3.1. Synopsis -command args 26.7.3.2.
  • Page 224: Command

    Chapter 26. The gdb/mi Interface 26.8.1.1. Synopsis -break-after number count The breakpoint number is not in effect until it has been hit times. To see how this number count is reflected in the output of the command, see the description of the -break-list -break-list command below.
  • Page 225: Break-Condition

    Chapter 26. The gdb/mi Interface 26.8.2.2. gdb Command The corresponding gdb command is condition 26.8.2.3. Example (gdb) -break-condition 1 1 ^done (gdb) -break-list ^done,BreakpointTable={nr_rows="1",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", addr="0x000100d0",func="main",file="hello.c",line="5",cond="1", times="0",ignore="3"}]} (gdb) 26.8.3. The Command -break-delete 26.8.3.1. Synopsis -break-delete ( breakpoint Delete the breakpoint(s) whose number(s) are specified in the argument list.
  • Page 226: Break-Disable

    Chapter 26. The gdb/mi Interface {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[]} (gdb) 26.8.4. The Command -break-disable 26.8.4.1. Synopsis -break-disable ( breakpoint Disable the named (s). The field in the break list is now set to for the named breakpoint enabled (s). breakpoint 26.8.4.2. gdb Command The corresponding gdb command is disable 26.8.4.3.
  • Page 227: Break-Enable

    Chapter 26. The gdb/mi Interface 26.8.5.1. Synopsis -break-enable ( breakpoint Enable (previously disabled) (s). breakpoint 26.8.5.2. gdb Command The corresponding gdb command is enable 26.8.5.3. Example (gdb) -break-enable 2 ^done (gdb) -break-list ^done,BreakpointTable={nr_rows="1",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[bkpt={number="2",type="breakpoint",disp="keep",enabled="y", addr="0x000100d0",func="main",file="hello.c",line="5",times="0"}]} (gdb) 26.8.6.
  • Page 228: Break-Insert

    Chapter 26. The gdb/mi Interface 26.8.7. The Command -break-insert 26.8.7.1. Synopsis -break-insert [ -t ] [ -h ] [ -r ] [ -c ] [ -i condition ignore-count [ -p thread line addr If specified, , can be one of: line function •...
  • Page 229: Break-List

    Chapter 26. The gdb/mi Interface 26.8.7.3. gdb Command The corresponding gdb commands are , and break tbreak hbreak thbreak rbreak 26.8.7.4. Example (gdb) -break-insert main ^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c",line="4"} (gdb) -break-insert -t foo ^done,bkpt={number="2",addr="0x00010774",file="recursive2.c",line="11"} (gdb) -break-list ^done,BreakpointTable={nr_rows="2",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}], body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", addr="0x0001072c", func="main",file="recursive2.c",line="4",times="0"}, bkpt={number="2",type="breakpoint",disp="del",enabled="y",...
  • Page 230: The -Break-Watch Command

    Chapter 26. The gdb/mi Interface Enabled is the breakpoint enabled or no: Address memory location at which the breakpoint is set What logical location of the breakpoint, expressed by function name, file name, line number Times number of times the breakpoint has been hit If there are no breakpoints or watchpoints, the field is an empty list.
  • Page 231 Chapter 26. The gdb/mi Interface 26.8.9. The Command -break-watch 26.8.9.1. Synopsis -break-watch [ -a | -r ] Create a watchpoint. With the option it will create an access watchpoint, that is, a watchpoint that triggers either on a read from or on a write to the memory location. With the option, the watchpoint created is a read watchpoint, that is, it will trigger only when the memory location is accessed for reading.
  • Page 232 Chapter 26. The gdb/mi Interface file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="18"} (gdb) Listing breakpoints and watchpoints, at different points in the program execution. Note that once the watchpoint goes out of scope, it is deleted. (gdb) -break-watch C ^done,wpt={number="2",exp="C"} (gdb) -break-list ^done,BreakpointTable={nr_rows="2",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type"}, {width="4",alignment="-1",col_name="disp",colhdr="Disp"}, {width="3",alignment="-1",col_name="enabled",colhdr="Enb"}, {width="10",alignment="-1",col_name="addr",colhdr="Address"}, {width="40",alignment="2",col_name="what",colhdr="What"}],...
  • Page 233: Command

    Chapter 26. The gdb/mi Interface body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y", addr="0x00010734",func="callee4", file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"}]} (gdb) 26.9. gdb/mi Data Manipulation This section describes the gdb/mi commands that manipulate data: examine memory and registers, evaluate expressions, etc. 26.9.1. The Command -data-disassemble 26.9.1.1. Synopsis -data-disassemble [ -s start-addr end-addr | [ -f [ -n filename...
  • Page 234 Chapter 26. The gdb/mi Interface 26.9.1.2. Result The output for each instruction is composed of four fields: Address • Func-name • Offset • Instruction • Note that whatever included in the instruction field, is not manipulated directely by gdb/mi, that is, it is not possible to adjust its format.
  • Page 235: Command

    Chapter 26. The gdb/mi Interface (gdb) -data-disassemble -f basics.c -l 32 -n 3 -- 0 ^done,asm_insns=[ {address="0x000107bc",func-name="main",offset="0", inst="save %sp, -112, %sp"}, {address="0x000107c0",func-name="main",offset="4", inst="mov 2, %o0"}, {address="0x000107c4",func-name="main",offset="8", inst="sethi %hi(0x11800), %o2"}] (gdb) Disassemble 3 instructions from the start of in mixed mode: main (gdb) -data-disassemble -f basics.c -l 32 -n 3 -- 1...
  • Page 236: Command

    Chapter 26. The gdb/mi Interface 26.9.2.3. Example In the following example, the numbers that precede the commands are the tokens described in (refer to Section 26.4 gdb/mi Command Syntax. Notice how gdb/mi returns the same tokens in its output. 211-data-evaluate-expression A 211^done,value="1"...
  • Page 237: Command

    Chapter 26. The gdb/mi Interface 26.9.4. The Command -data-list-register-names 26.9.4.1. Synopsis -data-list-register-names [ ( )+ ] regno Show a list of register names for the current target. If no arguments are given, it shows a list of the names of all the registers. If integer numbers are given as arguments, it will print a list of the names of the registers corresponding to the arguments.
  • Page 238 Chapter 26. The gdb/mi Interface Hexadecimal Octal Binary Decimal Natural 26.9.5.2. gdb Command The corresponding gdb commands are , and (in info reg info all-reg gdbtk gdb_fetch_registers 26.9.5.3. Example For a PPC MBX board (note: line breaks are for readability only, they don’t appear in the actual output): (gdb) -data-list-register-values r 64 65...
  • Page 239: Command

    Chapter 26. The gdb/mi Interface {number="41",value="0x0"},{number="42",value="0x0"}, {number="43",value="0x0"},{number="44",value="0x0"}, {number="45",value="0x0"},{number="46",value="0x0"}, {number="47",value="0x0"},{number="48",value="0x0"}, {number="49",value="0x0"},{number="50",value="0x0"}, {number="51",value="0x0"},{number="52",value="0x0"}, {number="53",value="0x0"},{number="54",value="0x0"}, {number="55",value="0x0"},{number="56",value="0x0"}, {number="57",value="0x0"},{number="58",value="0x0"}, {number="59",value="0x0"},{number="60",value="0x0"}, {number="61",value="0x0"},{number="62",value="0x0"}, {number="63",value="0x0"},{number="64",value="0xfe00a300"}, {number="65",value="0x29002"},{number="66",value="0x202f04b5"}, {number="67",value="0xfe0043b0"},{number="68",value="0xfe00b3e4"}, {number="69",value="0x20002b03"}] (gdb) 26.9.6. The Command -data-read-memory 26.9.6.1. Synopsis -data-read-memory [ -o byte-offset address word-format word-size nr-rows nr-cols aschar where: address An expression specifying the address of the first memory word to be read. Complex expressions containing embedded white space should be quoted using the C convention.
  • Page 240 Chapter 26. The gdb/mi Interface byte-offset An offset to add to the before fetching memory. address This command displays memory contents as a table of words, each word nr-rows nr-cols being bytes. In total, bytes are read (returned as word-size nr-rows nr-cols word-size...
  • Page 241: Command

    Chapter 26. The gdb/mi Interface {addr="0x000013b0",data=["0x20","0x21","0x22","0x23"],ascii=" !\"#"}, {addr="0x000013b4",data=["0x24","0x25","0x26","0x27"],ascii="$%&’"}, {addr="0x000013b8",data=["0x28","0x29","0x2a","0x2b"],ascii="()*+"}, {addr="0x000013bc",data=["0x2c","0x2d","0x2e","0x2f"],ascii=",-./"}] (gdb) 26.9.7. The Command -display-delete 26.9.7.1. Synopsis -display-delete number Delete the display number 26.9.7.2. gdb Command The corresponding gdb command is delete display 26.9.7.3. Example N.A. 26.9.8. The Command -display-disable 26.9.8.1.
  • Page 242: Command

    Chapter 26. The gdb/mi Interface 26.9.9. The Command -display-enable 26.9.9.1. Synopsis -display-enable number Enable display number 26.9.9.2. gdb Command The corresponding gdb command is enable display 26.9.9.3. Example N.A. 26.9.10. The Command -display-insert 26.9.10.1. Synopsis -display-insert expression Display every time the program stops. expression 26.9.10.2.
  • Page 243: Command

    Chapter 26. The gdb/mi Interface 26.9.11.2. gdb Command The corresponding gdb command is info display 26.9.11.3. Example N.A. 26.9.12. The Command -environment-cd 26.9.12.1. Synopsis -environment-cd pathdir Set gdb’s working directory. 26.9.12.2. gdb Command The corresponding gdb command is 26.9.12.3. Example (gdb) -environment-cd /kwikemart/marge/ezannoni/flathead-dev/devo/gdb ^done...
  • Page 244: Command

    Chapter 26. The gdb/mi Interface 26.9.13.2. gdb Command The corresponding gdb command is 26.9.13.3. Example (gdb) -environment-directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd" (gdb) -environment-directory "" ^done,source-path="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb:$cdir:$cwd" (gdb) -environment-directory -r /home/jjohnstn/src/gdb /usr/src ^done,source-path="/home/jjohnstn/src/gdb:/usr/src:$cdir:$cwd" (gdb) -environment-directory -r ^done,source-path="$cdir:$cwd" (gdb) 26.9.14. The Command -environment-path 26.9.14.1. Synopsis -environment-path [ -r ] [ pathdir Add directories...
  • Page 245: Gdb/Mi Program Control

    Chapter 26. The gdb/mi Interface ^done,path="/kwikemart/marge/ezannoni/flathead-dev/ppc-eabi/gdb:/bin:/usr/bin" (gdb) -environment-path -r /usr/local/bin ^done,path="/usr/local/bin:/usr/bin" (gdb) 26.9.15. The Command -environment-pwd 26.9.15.1. Synopsis -environment-pwd Show the current working directory. 26.9.15.2. gdb command The corresponding gdb command is 26.9.15.3. Example (gdb) -environment-pwd ^done,cwd="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb" (gdb) 26.10. gdb/mi Program control 26.10.1.
  • Page 246: Command Descriptions

    Chapter 26. The gdb/mi Interface *stopped,reason="exited-normally" (gdb) Program exited exceptionally: (gdb) -exec-run ^running (gdb) x = 55 *stopped,reason="exited",exit-code="01" (gdb) Another way the program can terminate is if it receives a signal such as . In this case, gdb/mi SIGINT displays this: (gdb) *stopped,reason="exited-signalled",signal-name="SIGINT", signal-meaning="Interrupt"...
  • Page 247: Exec-Arguments -Exec-Continue -Exec-Finish Command

    Chapter 26. The gdb/mi Interface 26.11.2.1. Synopsis -exec-arguments args Set the inferior program arguments, to be used in the next -exec-run 26.11.2.2. gdb Command The corresponding gdb command is set args 26.11.2.3. Example Don’t have one around. 26.11.3. The Command -exec-continue 26.11.3.1.
  • Page 248: Command

    Chapter 26. The gdb/mi Interface 26.11.4.1. Synopsis -exec-finish Asynchronous command. Resumes the execution of the inferior program until the current function is exited. Displays the results returned by the function. 26.11.4.2. gdb Command The corresponding gdb command is finish 26.11.4.3. Example Function returning void -exec-finish...
  • Page 249: Command

    Chapter 26. The gdb/mi Interface 26.11.5.2. gdb Command The corresponding gdb command is interrupt 26.11.5.3. Example (gdb) 111-exec-continue 111^running (gdb) 222-exec-interrupt 222^done (gdb) 111*stopped,signal-name="SIGINT",signal-meaning="Interrupt", frame={addr="0x00010140",func="foo",args=[],file="try.c",line="13"} (gdb) (gdb) -exec-interrupt ^error,msg="mi_cmd_exec_interrupt: Inferior not executing." (gdb) 26.11.6. The Command -exec-next 26.11.6.1. Synopsis -exec-next Asynchronous command.
  • Page 250: The -Exec-Abort Command

    Chapter 26. The gdb/mi Interface 26.11.7. The Command -exec-next-instruction 26.11.7.1. Synopsis -exec-next-instruction Asynchronous command. Executes one machine instruction. If the instruction is a function call con- tinues until the function returns. If the program stops at an instruction in the middle of a source line, the address will be printed as well.
  • Page 251: Exec-Run

    Chapter 26. The gdb/mi Interface 26.11.8.3. Example (gdb) 200-break-insert callee4 200^done,bkpt={number="1",addr="0x00010734", file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"} (gdb) 000-exec-run 000^running (gdb) 000*stopped,reason="breakpoint-hit",bkptno="1", frame={func="callee4",args=[], file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"} (gdb) 205-break-delete 205^done (gdb) 111-exec-return 111^done,frame={level="0",func="callee3", args=[{name="strarg", value="0x11940 \"A string argument.\""}], file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="18"} (gdb) 26.11.9. The Command -exec-run 26.11.9.1. Synopsis -exec-run Asynchronous command. Starts execution of the inferior from the beginning. The inferior executes until either a breakpoint is encountered or the program exits.
  • Page 252: Exec-Show-Arguments

    Chapter 26. The gdb/mi Interface 26.11.10. The Command -exec-show-arguments 26.11.10.1. Synopsis -exec-show-arguments Print the arguments of the program. 26.11.10.2. gdb Command The corresponding gdb command is show args 26.11.10.3. Example N.A. 26.11.11. The Command -exec-step 26.11.11.1. Synopsis -exec-step Asynchronous command. Resumes execution of the inferior program, stopping when the beginning of the next source line is reached, if the next source line is not a function call.
  • Page 253: Command

    Chapter 26. The gdb/mi Interface Regular stepping: -exec-step ^running (gdb) *stopped,reason="end-stepping-range",line="14",file="recursive2.c" (gdb) 26.11.12. The Command -exec-step-instruction 26.11.12.1. Synopsis -exec-step-instruction Asynchronous command. Resumes the inferior which executes one machine instruction. The output, once gdb has stopped, will vary depending on whether we have stopped in the middle of a source line or not.
  • Page 254: Exec-Until

    Chapter 26. The gdb/mi Interface 26.11.13.1. Synopsis -exec-until [ location Asynchronous command. Executes the inferior until the specified in the argument is location reached. If there is no argument, the inferior executes until a source line greater than the current one is reached.
  • Page 255: File-Exec-File

    Chapter 26. The gdb/mi Interface 26.11.14.3. Example (gdb) -file-exec-and-symbols /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx ^done (gdb) 26.11.15. The Command -file-exec-file 26.11.15.1. Synopsis -file-exec-file file Specify the executable file to be debugged. Unlike , the symbol table is -file-exec-and-symbols not read from this file. If used without argument, gdb clears the information about the executable file. No output is produced, except a completion notification.
  • Page 256: File-List-Exec-Source-File

    Chapter 26. The gdb/mi Interface 26.11.16.2. gdb Command The gdb command shows, among the rest, the same information as this command. info file gdbtk has a corresponding command gdb_load_info 26.11.16.3. Example N.A. 26.11.17. The Command -file-list-exec-source-file 26.11.17.1. Synopsis -file-list-exec-source-file List the line number, the current source file, and the absolute path to the current source file for the current executable.
  • Page 257: File-List-Shared-Libraries

    Chapter 26. The gdb/mi Interface 26.11.18.2. gdb Command There’s no gdb command which directly corresponds to this one. has an analogous command gdbtk gdb_listfiles 26.11.18.3. Example N.A. 26.11.19. The Command -file-list-shared-libraries 26.11.19.1. Synopsis -file-list-shared-libraries List the shared libraries in the program. 26.11.19.2.
  • Page 258: Miscellaneous Gdb Commands In Gdb/Mi

    Chapter 26. The gdb/mi Interface 26.11.21. The Command -file-symbol-file 26.11.21.1. Synopsis -file-symbol-file file Read symbol table info from the specified argument. When used without arguments, clears gdb’s file symbol table info. No output is produced, except for a completion notification. 26.11.21.2.
  • Page 259: Gdb-Set

    Chapter 26. The gdb/mi Interface 26.12.1.3. Example (gdb) -gdb-exit 26.12.2. The Command -gdb-set 26.12.2.1. Synopsis -gdb-set Set an internal gdb variable. 26.12.2.2. gdb Command The corresponding gdb command is 26.12.2.3. Example (gdb) -gdb-set $foo=3 ^done (gdb) 26.12.3. The Command -gdb-show 26.12.3.1.
  • Page 260: Synopsis

    Chapter 26. The gdb/mi Interface 26.12.3.3. Example (gdb) -gdb-show annotate ^done,value="0" (gdb) 26.12.4. The Command -gdb-version 26.12.4.1. Synopsis -gdb-version Show version information for gdb. Used mostly in testing. 26.12.4.2. gdb Command There’s no equivalent gdb command. gdb by default shows this information when you start an inter- active session.
  • Page 261: Gdb Command

    Chapter 26. The gdb/mi Interface 26.12.6. Synopsis -interpreter-exec interpreter command Execute the specified in the given command interpreter 26.12.7. gdb Command The corresponding gdb command is interpreter-exec 26.12.8. Example (gdb) -interpreter-exec console "break main" &"During symbol reading, couldn’t parse type; debugger out of date?.\n" &"During symbol reading, bad structure-type format.\n"...
  • Page 262: Command

    Chapter 26. The gdb/mi Interface 26.13.2.1. Synopsis -stack-info-depth [ max-depth Return the depth of the stack. If the integer argument is specified, do not count beyond max-depth frames. max-depth 26.13.2.2. gdb Command There’s no equivalent gdb command. 26.13.2.3. Example For a stack with frame levels 0 through 11: (gdb) -stack-info-depth ^done,depth="12"...
  • Page 263: Stack-List-Arguments

    Chapter 26. The gdb/mi Interface 26.13.3.2. gdb Command gdb does not have an equivalent command. has a command which partially gdbtk gdb_get_args overlaps with the functionality of -stack-list-arguments 26.13.3.3. Example (gdb) -stack-list-frames ^done, stack=[ frame={level="0",addr="0x00010734",func="callee4", file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="8"}, frame={level="1",addr="0x0001076c",func="callee3", file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="17"}, frame={level="2",addr="0x0001078c",func="callee2", file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="22"}, frame={level="3",addr="0x000107b4",func="callee1", file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="27"}, frame={level="4",addr="0x000107e0",func="main",...
  • Page 264 Chapter 26. The gdb/mi Interface 26.13.4. The Command -stack-list-frames 26.13.4.1. Synopsis -stack-list-frames [ low-frame high-frame List the frames currently on the stack. For each frame it displays the following info: level The frame number, 0 being the topmost frame, that is, the innermost function. addr value for that frame.
  • Page 265 Chapter 26. The gdb/mi Interface file="recursive2.c",line="14"}, frame={level="7",addr="0x000107a4",func="foo", file="recursive2.c",line="14"}, frame={level="8",addr="0x000107a4",func="foo", file="recursive2.c",line="14"}, frame={level="9",addr="0x000107a4",func="foo", file="recursive2.c",line="14"}, frame={level="10",addr="0x000107a4",func="foo", file="recursive2.c",line="14"}, frame={level="11",addr="0x00010738",func="main", file="recursive2.c",line="4"}] (gdb) Show frames between low_frame high_frame (gdb) -stack-list-frames 3 5 ^done,stack= [frame={level="3",addr="0x000107a4",func="foo", file="recursive2.c",line="14"}, frame={level="4",addr="0x000107a4",func="foo", file="recursive2.c",line="14"}, frame={level="5",addr="0x000107a4",func="foo", file="recursive2.c",line="14"}] (gdb) Show a single frame: (gdb) -stack-list-frames 3 3 ^done,stack= [frame={level="3",addr="0x000107a4",func="foo", file="recursive2.c",line="14"}]...
  • Page 266: Gdb/Mi Symbol Query Commands

    Chapter 26. The gdb/mi Interface 26.13.5.2. gdb Command in gdb, info locals gdb_get_locals gdbtk 26.13.5.3. Example (gdb) -stack-list-locals 0 ^done,locals=[name="A",name="B",name="C"] (gdb) -stack-list-locals 1 ^done,locals=[{name="A",value="1"},{name="B",value="2"}, {name="C",value="3"}] (gdb) 26.13.6. The Command -stack-select-frame 26.13.6.1. Synopsis -stack-select-frame framenum Change the current frame. Select a different frame on the stack.
  • Page 267: Command

    Chapter 26. The gdb/mi Interface 26.14.1.1. Synopsis -symbol-info-address symbol Describe where is stored. symbol 26.14.1.2. gdb Command The corresponding gdb command is info address 26.14.1.3. Example N.A. 26.14.2. The Command -symbol-info-file 26.14.2.1. Synopsis -symbol-info-file Show the file for the symbol. 26.14.2.2.
  • Page 268: Command

    Chapter 26. The gdb/mi Interface 26.14.3.2. gdb Command gdb_get_function gdbtk 26.14.3.3. Example N.A. 26.14.4. The Command -symbol-info-line 26.14.4.1. Synopsis -symbol-info-line Show the core addresses of the code for a source line. 26.14.4.2. gdb Command The corresponding gdb comamnd is has the info line gdbtk gdb_get_line...
  • Page 269: Command

    Chapter 26. The gdb/mi Interface 26.14.6. The Command -symbol-list-functions 26.14.6.1. Synopsis -symbol-list-functions List the functions in the executable. 26.14.6.2. gdb Command in gdb, info functions gdb_listfunc gdb_search gdbtk 26.14.6.3. Example N.A. 26.14.7. The Command -symbol-list-lines 26.14.7.1. Synopsis -symbol-list-lines filename Print the list of lines that contain code and their associated program addresses for the given source filename.
  • Page 270: Command

    Chapter 26. The gdb/mi Interface 26.14.8.1. Synopsis -symbol-list-types List all the type names. 26.14.8.2. gdb Command The corresponding commands are in gdb, info types gdb_search gdbtk 26.14.8.3. Example N.A. 26.14.9. The Command -symbol-list-variables 26.14.9.1. Synopsis -symbol-list-variables List all the global and static variable names. 26.14.9.2.
  • Page 271: Gdb/Mi Target Manipulation Commands

    Chapter 26. The gdb/mi Interface 26.14.10.2. gdb Command gdb_loc gdbtk 26.14.10.3. Example N.A. 26.14.11. The Command -symbol-type 26.14.11.1. Synopsis -symbol-type variable Show type of variable 26.14.11.2. gdb Command The corresponding gdb command is ptype gdbtk gdb_obj_variable 26.14.11.3. Example N.A. 26.15. gdb/mi Target Manipulation Commands 26.15.1.
  • Page 272: Command

    Chapter 26. The gdb/mi Interface 26.15.1.3. Example N.A. 26.15.2. The Command -target-compare-sections 26.15.2.1. Synopsis -target-compare-sections [ section Compare data of section on target to the exec file. Without the argument, all sections are section compared. 26.15.2.2. gdb Command The gdb equivalent is compare-sections 26.15.2.3.
  • Page 273: Command

    Chapter 26. The gdb/mi Interface 26.15.4. The Command -target-disconnect 26.15.4.1. Synopsis -target-disconnect Disconnect from the remote target. There’s no output. 26.15.4.2. gdb command The corresponding gdb command is disconnect 26.15.4.3. Example (gdb) -target-disconnect ^done (gdb) 26.15.5. The Command -target-download 26.15.5.1. Synopsis -target-download Loads the executable onto the remote target.
  • Page 274 Chapter 26. The gdb/mi Interface total-size The size of the overall executable to download. Each message is sent as status record (refer to Section 26.4.2 gdb/mi Output Syntax). In addition, it prints the name and size of the sections, as they are downloaded. These messages include the following fields: section The name of the section.
  • Page 275: Command

    Chapter 26. The gdb/mi Interface +download,{section=".init",section-size="28",total-size="9880"} +download,{section=".fini",section-size="28",total-size="9880"} +download,{section=".data",section-size="3156",total-size="9880"} +download,{section=".data",section-sent="512",section-size="3156", total-sent="7236",total-size="9880"} +download,{section=".data",section-sent="1024",section-size="3156", total-sent="7748",total-size="9880"} +download,{section=".data",section-sent="1536",section-size="3156", total-sent="8260",total-size="9880"} +download,{section=".data",section-sent="2048",section-size="3156", total-sent="8772",total-size="9880"} +download,{section=".data",section-sent="2560",section-size="3156", total-sent="9284",total-size="9880"} +download,{section=".data",section-sent="3072",section-size="3156", total-sent="9796",total-size="9880"} ^done,address="0x10004",load-size="9880",transfer-rate="6586", write-rate="429" (gdb) 26.15.6. The Command -target-exec-status 26.15.6.1. Synopsis -target-exec-status Provide information on the state of the target (whether it is running or not, for instance). 26.15.6.2.
  • Page 276: Command

    Chapter 26. The gdb/mi Interface 26.15.7.2. gdb Command The corresponding gdb command is help target 26.15.7.3. Example N.A. 26.15.8. The Command -target-list-current-targets 26.15.8.1. Synopsis -target-list-current-targets Describe the current target. 26.15.8.2. gdb Command The corresponding information is printed by (among other things). info file 26.15.8.3.
  • Page 277: Gdb/Mi Thread Commands

    Chapter 26. The gdb/mi Interface 26.15.10. The Command -target-select 26.15.10.1. Synopsis -target-select type parameters ... Connect gdb to the remote target. This command takes two args: type The type of target, for instance , etc. async remote parameters Device names, host names and the like. Refer to Section 18.2 Commands for managing targets, for more details.
  • Page 278: Command

    Chapter 26. The gdb/mi Interface 26.16.1.1. Synopsis -thread-info 26.16.1.2. gdb command No equivalent. 26.16.1.3. Example N.A. 26.16.2. The Command -thread-list-all-threads 26.16.2.1. Synopsis -thread-list-all-threads 26.16.2.2. gdb Command The equivalent gdb command is info threads 26.16.2.3. Example N.A. 26.16.3. The Command -thread-list-ids 26.16.3.1.
  • Page 279: Command

    Chapter 26. The gdb/mi Interface 26.16.3.3. Example No threads present, besides the main process: (gdb) -thread-list-ids ^done,thread-ids={},number-of-threads="0" (gdb) Several threads: (gdb) -thread-list-ids ^done,thread-ids={thread-id="3",thread-id="2",thread-id="1"}, number-of-threads="3" (gdb) 26.16.4. The Command -thread-select 26.16.4.1. Synopsis -thread-select threadnum Make the current thread. It prints the number of the new current thread, and the topmost threadnum frame for that thread.
  • Page 280: The

    Chapter 26. The gdb/mi Interface args=[{name="format",value="0x8048e9c \"%*s%c %d %c\\n\""}, {name="arg",value="0x2"}],file="vprintf.c",line="31"} (gdb) 26.17. gdb/mi Tracepoint Commands The tracepoint commands are not yet implemented. 26.18. gdb/mi Variable Objects 26.18.1. Motivation for Variable Objects in gdb/mi For the implementation of a variable debugger window (locals, watched expressions, etc.), we are proposing the adaptation of the existing code used by Insight The two main reasons for that are:...
  • Page 281: Description And Use Of Operations On Variable Objects

    Chapter 26. The gdb/mi Interface Operation Description create a variable object -var-create delete the variable object and its children -var-delete set the display format of this variable -var-set-format show the display format of this variable -var-show-format tells how many children this object has -var-info-num-children return a list of the object’s children -var-list-children...
  • Page 282: Command

    Chapter 26. The gdb/mi Interface -- a CPU register name • regname 26.18.4.2. Result This operation returns the name, number of children and the type of the object created. Type is returned as a string as the ones generated by the gdb CLI: name="...
  • Page 283: Command

    Chapter 26. The gdb/mi Interface 26.18.7.1. Synopsis -var-show-format name Returns the format used to display the value of the object name ==> format format-spec 26.18.8. The Command -var-info-num-children 26.18.8.1. Synopsis -var-info-num-children name Returns the number of children of a variable object name numchild= 26.18.9.
  • Page 284: Command

    Chapter 26. The gdb/mi Interface 26.18.10.1. Synopsis -var-info-type name Returns the type of the specified variable . The type is returned as a string in the same format as name it is output by the gdb CLI: type= typename 26.18.11. The Command -var-info-expression 26.18.11.1.
  • Page 285: Command

    Chapter 26. The gdb/mi Interface 26.18.13.1. Synopsis -var-evaluate-expression name Evaluates the expression that is represented by the specified variable object and returns its value as a string in the current format specified for the object: value= value Note that one must invoke for a variable before the value of a child variable -var-list-children can be evaluated.
  • Page 286 Chapter 26. The gdb/mi Interface Update the value of the variable object by evaluating its expression after fetching all the new name values from memory or registers. A causes all existing variable objects to be updated.
  • Page 287: Gdb Annotations

    Chapter 27. gdb Annotations This chapter describes annotations in gdb. Annotations are designed to interface gdb to graphical user interfaces or other similar programs which want to interact with gdb at a relatively high level. 27.1. What is an Annotation? To produce annotations, start gdb with the option.
  • Page 288: Values

    Chapter 27. gdb Annotations 27.3. Values When a value is printed in various contexts, gdb uses annotations to delimit the value from the sur- rounding text. If a value is printed using and added to the value history, the annotation looks like print ^Z^Zvalue-history-begin history-number value-flags...
  • Page 289: Frames

    Chapter 27. gdb Annotations When printing an array, gdb annotates it as follows: ^Z^Zarray-section-begin array-index value-flags where is the index of the first element being annotated and has the same array-index value-flags meaning as in a annotation. This is followed by any number of elements, value-history-begin where is element can be either a single element: ;...
  • Page 290 Chapter 27. gdb Annotations Between these annotations is the main body of the frame, which can consist of • ^Z^Zfunction-call function-call-string where is text designed to convey to the user that this frame is associated function-call-string with a function call made by gdb to a function in the program being debugged. •...
  • Page 291: Displays

    Chapter 27. gdb Annotations Then, if source is to actually be displayed for this frame (for example, this is not true for output from command), then a annotation (refer to Section 27.11 Displaying Source) is backtrace source displayed. Unlike most annotations, this is output instead of the normal text which would be output, not in addition.
  • Page 292: Errors

    Chapter 27. gdb Annotations commands When gdb prompts for a set of commands, like in the command. The annotations are commands repeated for each command which is input. overload-choice When gdb wants the user to select between various overloaded functions. query When gdb wants the user to confirm a potentially dangerous operation.
  • Page 293: Invalidation Notices

    Chapter 27. gdb Annotations where has the same syntax as an entry (see below) but instead of containing data, it header-entry contains strings which are intended to convey the meaning of each field to the user. This is followed by any number of entries. If a field does not apply for this entry, it is omitted. Fields may contain trailing whitespace.
  • Page 294: Running The Program

    Chapter 27. gdb Annotations 27.10. Running the Program When the program starts executing due to a gdb command such as step continue ^Z^Zstarting is output. When the program stops, ^Z^Zstopped is output. Before the annotation, a variety of annotations describe how the program stopped. stopped ^Z^Zexited exit-status...
  • Page 295: Annotations We Might Want In The Future

    Chapter 27. gdb Annotations where is an absolute file name indicating which source file, is the line number within filename line that file (where 1 is the first line in the file), is the character position within the file (where character 0 is the first character in the file) (for most debug formats this will necessarily point to the beginning of a line),...
  • Page 296 Chapter 27. gdb Annotations...
  • Page 297: Reporting Bugs In Gdb

    Chapter 28. Reporting Bugs in gdb Your bug reports play an essential role in making gdb reliable. Reporting a bug may help you by bringing a solution to your problem, or it may not. But in any case the principal function of a bug report is to help the entire community by making the next version of gdb work better.
  • Page 298 Chapter 28. Reporting Bugs in gdb does not matter. Well, probably it does not, but one cannot be sure. Perhaps the bug is a stray memory reference which happens to fetch from the location where that name is stored in memory; perhaps, if the name were different, the contents of that location would fool the debugger into doing the right thing despite the bug.
  • Page 299 Chapter 28. Reporting Bugs in gdb This is often time consuming and not very useful, because the way we will find the bug is by running a single example under the debugger with breakpoints, not by pure deduction from a series of examples.
  • Page 300 Chapter 28. Reporting Bugs in gdb...
  • Page 301: Command Line Editing

    Chapter 29. Command Line Editing This chapter describes the basic features of the gnu command line editing interface. 29.1. Introduction to Line Editing The following paragraphs describe the notation used to represent keystrokes. The text C-k is read as ‘Control-K’ and describes the character produced when the [k] key is pressed while the Control key is depressed.
  • Page 302: Readline Movement Commands

    Chapter 29. Command Line Editing Move back one character. Move forward one character. [DEL] or [Backspace] Delete the character to the left of the cursor. Delete the character underneath the cursor. Printing characters Insert the character into the line at the cursor. C-_ or C-x C-u Undo the last editing command.
  • Page 303: Readline Arguments

    Chapter 29. Command Line Editing 29.2.3. Readline Killing Commands Killing text means to delete the text from the line, but to save it away for later use, usually by yanking (re-inserting) it back into the line. (‘Cut’ and ‘paste’ are more recent jargon for ‘kill’ and ‘yank’.) If the description for a command says that it ‘kills’...
  • Page 304: Searching For Commands In The History

    Chapter 29. Command Line Editing 29.2.5. Searching for Commands in the History Readline provides commands for searching through the command history for lines containing a spec- ified string. There are two search modes: incremental and non-incremental. Incremental searches begin before the user has finished typing the search string. As each character of the search string is typed, Readline displays the next entry from the history matching the string typed so far.
  • Page 305 Chapter 29. Command Line Editing Variable names and values, where appropriate, are recognized without regard to case. A great deal of run-time behavior is changeable with the following variables. bell-style Controls what happens when Readline wants to ring the terminal bell. If set to , Read- none line never rings the bell.
  • Page 306 Chapter 29. Command Line Editing width of the screen, instead of wrapping onto a new screen line. By default, this variable is set to input-meta If set to , Readline will enable eight-bit input (it will not clear the eighth bit in the char- acters it reads), regardless of what the terminal claims it can support.
  • Page 307 Chapter 29. Command Line Editing show-all-if-ambiguous This alters the default behavior of the completion functions. If set to , words which have more than one possible completion cause the matches to be listed immediately instead of ringing the bell. The default value is visible-stats If set to , a character denoting a file’s type is appended to the filename when listing...
  • Page 308 Chapter 29. Command Line Editing an escape character backslash \" ["], a double quotation mark \’ [’], a single quote or apostrophe In addition to the gnu Emacs style escape sequences, a second set of backslash escapes is avail- able: alert (bell) backspace delete...
  • Page 309: Conditional Init Constructs

    Chapter 29. Command Line Editing 29.3.2. Conditional Init Constructs Readline implements a facility similar in spirit to the conditional compilation features of the C pre- processor which allows key bindings and variable settings to be performed as the result of tests. There are four parser directives used.
  • Page 310 Chapter 29. Command Line Editing # programs that use the GNU Readline library. Existing # programs include FTP, Bash, and GDB. # You can re-read the inputrc file with C-x C-r. # Lines beginning with ’#’ are comments. # First, include any systemwide bindings and variable # assignments from /etc/Inputrc $include /etc/Inputrc # Set various bindings for emacs mode.
  • Page 311: Bindable Readline Commands

    Chapter 29. Command Line Editing "\C-x\"": "\"\"\C-b" # insert a backslash (testing backslash escapes # in sequences and macros) "\C-x\\": "\\" # Quote the current or previous word "\C-xq": "\eb\"\ef\"" # Add a binding to refresh the line, which is unbound "\C-xr": redraw-current-line # Edit variable on current line.
  • Page 312: Commands For Manipulating The History

    Chapter 29. Command Line Editing forward-char (C-f) Move forward a character. backward-char (C-b) Move back a character. forward-word (M-f) Move forward to the end of the next word. Words are composed of letters and digits. backward-word (M-b) Move back to the start of the current or previous word. Words are composed of letters and digits. clear-screen (C-l) Clear the screen and redraw the current line, leaving the current line at the top of the screen.
  • Page 313: Commands For Changing Text

    Chapter 29. Command Line Editing non-incremental-forward-search-history (M-n) Search forward starting at the current line and moving ‘down’ through the the history as necessary using a non-incremental search for a string supplied by the user. history-search-forward () Search forward through the history for the string of characters between the start of the current line and the point.
  • Page 314: Killing And Yanking

    Chapter 29. Command Line Editing transpose-chars (C-t) Drag the character before the cursor forward over the character at the cursor, moving the cursor forward as well. If the insertion point is at the end of the line, then this transposes the last two characters of the line.
  • Page 315: Specifying Numeric Arguments

    Chapter 29. Command Line Editing backward-kill-word (M-[DEL]) Kill the word behind point. Word boundaries are the same as backward-word unix-word-rubout (C-w) Kill the word behind point, using white space as a word boundary. The killed text is saved on the kill-ring.
  • Page 316: Letting Readline Type For You

    Chapter 29. Command Line Editing 29.4.6. Letting Readline Type For You complete ([TAB]) Attempt to perform completion on the text before point. The actual completion performed is application-specific. The default is filename completion. possible-completions (M-?) List the possible completions of the text before point. insert-completions (M-*) Insert all completions of the text before point that would have been generated by possible-completions...
  • Page 317 Chapter 29. Command Line Editing do-uppercase-version (M-a, M-b, M- , ...) If the metafied character is lowercase, run the command that is bound to the corresponding uppercase character. prefix-meta ([ESC]) Metafy the next character typed. This is for keyboards without a meta key. Typing [ESC] f equivalent to typing M-f.
  • Page 318: Readline Vi Mode

    Chapter 29. Command Line Editing dump-macros () Print all of the Readline key sequences bound to macros and the strings they output. If a numeric argument is supplied, the output is formatted in such a way that it can be made part of an inputrc file.
  • Page 319: Using History Interactively

    Chapter 30. Using History Interactively This chapter describes how to use the GNU History Library interactively, from a user’s standpoint. It should be considered a user’s guide. 30.1. History Expansion The History library provides a history expansion feature that is similar to the history expansion pro- vided by .
  • Page 320: Word Designators

    Chapter 30. Using History Interactively The entire command line typed so far. 30.1.2. Word Designators Word designators are used to select desired words from the event. A separates the event specification from the word designator. It may be omitted if the word designator begins with a , or .
  • Page 321: Modifiers

    Chapter 30. Using History Interactively Abbreviates like , but omits the last word. If a word designator is supplied without an event specification, the previous command is used as the event. 30.1.3. Modifiers After the optional word designator, you can add a sequence of one or more of the following modifiers, each preceded by a Remove a trailing pathname component, leaving only the head.
  • Page 322 Chapter 30. Using History Interactively...
  • Page 323: Formatting Documentation

    Appendix A. Formatting Documentation The gdb 4 release includes an already-formatted reference card, ready for printing with PostScript or Ghostscript, in the subdirectory of the main source directory . If you can use PostScript or Ghostscript with your printer, you can print the reference card immediately with refcard.ps The release also includes the source for the reference card.
  • Page 324 Appendix A. Formatting Documentation If you have TeX and a dvi printer program installed, you can typeset and print this manual. First switch to the the subdirectory of the main source directory (for example, to ) and type: gdb-2003-07-22-cvs/gdb make gdb.dvi Then give to your dvi printing program.
  • Page 325: Installing Gdb

    Appendix B. Installing gdb gdb comes with a script that automates the process of preparing gdb for installation; you configure can then use to build the program. make The gdb distribution includes all the source code you need for gdb in a single directory, whose name is usually composed by appending the version number to For example, the gdb version 2003-07-22-cvs distribution is in the directory.
  • Page 326: Compiling Gdb In Another Directory

    Appendix B. Installing gdb where is an identifier such as , that identifies the platform where gdb will host sun4 decstation run. (You can often leave off tries to guess the correct value by examining your host configure system.) Running and then running builds the , and...
  • Page 327: Specifying Names For Hosts And Targets

    Appendix B. Installing gdb In the example, you’d find the Sun 4 library in the directory libiberty.a gdb-sun4/libiberty and gdb itself in gdb-sun4/gdb Make sure that your path to the script has just one instance of in it. If your path to configure looks like , you are configuring only one...
  • Page 328: Configure Options

    Appendix B. Installing gdb B.3. options configure Here is a summary of the options and arguments that are most often useful for building configure gdb. also has several other options not listed here. *note (configure.info)What Configure configure Does::, for a full explanation of configure configure [--help] [--prefix=...
  • Page 329 Appendix C. Maintenance Commands In addition to commands intended for gdb users, gdb includes a number of commands intended for gdb developers. These commands are provided here for reference. maint info breakpoints Using the same format as , display both the breakpoints you’ve set explic- info breakpoints itly, and those gdb is using for internal purposes.
  • Page 330: C. Maintenance Commands

    Appendix C. Maintenance Commands maint print dummy-frames Prints the contents of gdb’s internal dummy-frame stack. (gdb) b add (gdb) print add(2,3) Breakpoint 2, add (a=2, b=3) at ... return (a + b); The program being debugged stopped while in a function called from GDB. (gdb) maint print dummy-frames 0x1a57c80: pc=0x01014068 fp=0x0200bddc sp=0x0200bdd6 top=0x0200bdd4 id={stack=0x200bddc,code=0x101405c}...
  • Page 331: Gdb Remote Serial Protocol

    Appendix D. gdb Remote Serial Protocol D.1. Overview There may be occasions when you need to know something about the protocol--for example, if there is only one serial port to your target machine, you might want your program to do something special if it recognizes a packet meant for gdb.
  • Page 332: Packets

    Appendix D. gdb Remote Serial Protocol win). The printable characters or with a numeric value greater than 126 should not be used. Some remote systems have used a different run-length encoding mechanism loosely refered to as the cisco encoding. Following the character are two hex digits that indicate the size of the packet.
  • Page 333 Appendix D. gdb Remote Serial Protocol -- set baud (deprecated) bbaud Change the serial line speed to baud JTC: When does the transport layer state change? When it’s received, or after the ACK is trans- mitted. In either case, there are problems if the command or the acknowledgment packet is dropped.
  • Page 334 Appendix D. gdb Remote Serial Protocol -- read registers Read general registers. Reply: XX... Each byte of register data is described by two hex digits. The bytes with the register are transmitted in target byte order. The size of each register and their position within are determined by the gdb internal macros g packet REGISTER_RAW_SIZE...
  • Page 335 Appendix D. gdb Remote Serial Protocol -- signal then cycle step (reserved) -- reserved Reserved for future use. -- reserved Reserved for future use. -- kill request FIXME: There is no description of how to operate when a specific thread context has been selected (that is, does ’k’...
  • Page 336 Appendix D. gdb Remote Serial Protocol -- reserved Reserved for future use. -- reserved Reserved for future use. -- reserved Reserved for future use. -- reserved Reserved for future use. -- read reg (reserved) pn... Reply: r..The hex encoded value of the register in target byte order. -- write register Pn...=r...
  • Page 337 Appendix D. gdb Remote Serial Protocol -- general set Qvar=val Set value of Refer to Section D.4 General Query Packets, for a discussion of naming conventions. -- reset (deprecated) Reset the entire system. -- remote restart Restart the program being debugged. , while needed, is ignored.
  • Page 338 Appendix D. gdb Remote Serial Protocol -- reserved Reserved for future use. -- reserved Reserved for future use. -- reserved Reserved for future use. -- reserved Reserved for future use. -- write mem (binary) Xaddr,length:XX... is address, is number of bytes, is binary data.
  • Page 339 Appendix D. gdb Remote Serial Protocol Implementation note: It is possible for a target to copy or move code that contains memory breakpoints (e.g., when implementing overlays). The behavior of this packet, in the presence of such a target, is not defined. Reply: success not supported...
  • Page 340: Stop Reply Packets

    Appendix D. gdb Remote Serial Protocol -- remove read watchpoint (draft) z3,addr,length -- insert read watchpoint (draft) Z3,addr,length Insert ( ) or remove ( ) a read watchpoint. Reply: success not supported for an error -- remove access watchpoint (draft) z4,addr,length -- insert access watchpoint (draft) Z4,addr,length...
  • Page 341: General Query Packets

    Appendix D. gdb Remote Serial Protocol The process terminated with signal t... d... b... (obsolete) = signal number; = address of symbol = base of data section; t... _start d... b... base of bss section. Note: only used by Cisco Systems targets. The difference between this reply and the query is that the packet may arrive spontaneously whereas the...
  • Page 342 Appendix D. gdb Remote Serial Protocol Reply: A single thread id a comma-separated list of thread ids (lower case ’el’) denotes end of list. In response to each query, the target will reply with a list of one or more thread ids, in big-endian hex, separated by commas.
  • Page 343 Appendix D. gdb Remote Serial Protocol CCRC32 A 32 bit cyclic redundancy check of the specified memory region. -- query sect offs qOffsets Get section offsets that the target used when re-locating the downloaded image. Note: while a offset is included in the response, gdb ignores this and instead applies the offset to the Data section.
  • Page 344: Register Packet Format

    Appendix D. gdb Remote Serial Protocol The target does not need to look up any (more) symbols. qSymbol:sym_name The target requests the value of symbol (hex encoded). gdb may provide the sym_name value by using the message, described below. qSymbol:sym_value sym_name -- symbol value qSymbol:sym_value...
  • Page 345: File-I/O Remote Protocol Extension

    Appendix D. gdb Remote Serial Protocol T001:1234123412341234 Example sequence of a target being stepped by a single instruction: G1445... time passes T001:1234123412341234 1455... D.7. File-I/O remote protocol extension D.7.1. File-I/O Overview The File I/O remote protocol extension (short: File-I/O) allows the target to use the hosts file system and console I/O when calling various system calls.
  • Page 346: Protocol Basics

    Appendix D. gdb Remote Serial Protocol D.7.2. Protocol basics The File-I/O protocol uses the packet, as request as well as as reply packet. Since a File-I/O system call can only occur when gdb is waiting for the continuing or stepping target, the File-I/O request is a reply that gdb has to expect as a result of a former packet.
  • Page 347: Memory Transfer

    Appendix D. gdb Remote Serial Protocol D.7.4. The reply packet reply packet has the following format: Fretcode,errno,Ctrl-C flag;call specific attachment is the return code of the system call as hexadecimal value. is the errno set by the retcode errno call, in protocol specific representation. This parameter can be omitted if the call was successful. is only send if the user requested a break.
  • Page 348: The Isatty(3) Call

    Appendix D. gdb Remote Serial Protocol The user presses Ctrl-C. The behaviour is as explained above, the system call is treated as • read finished. The user presses Enter. This is treated as end of input with a trailing line feed. •...
  • Page 349 Appendix D. gdb Remote Serial Protocol D.7.10.1. open Synopsis: int open(const char *pathname, int flags); int open(const char *pathname, int flags, mode_t mode); Request: Fopen,pathptr/len,flags,mode is the bitwise or of the following values: flags O_CREAT If the file does not exist it will be created. The host rules apply as far as file ownership and time stamps are concerned.
  • Page 350 Appendix D. gdb Remote Serial Protocol S_IWOTH Others have write permission. Each other bit is silently ignored. Return value: open returns the new file descriptor or -1 if an error occured. Errors: EEXIST pathname already exists and O_CREAT and O_EXCL were used. EISDIR pathname refers to a directory.
  • Page 351 Appendix D. gdb Remote Serial Protocol D.7.10.2. close Synopsis: int close(int fd); Request: Fclose,fd Return value: close returns zero on success, or -1 if an error occurred. Errors: EBADF fd isn’t a valid open file descriptor. EINTR The call was interrupted by the user. D.7.10.3.
  • Page 352 Appendix D. gdb Remote Serial Protocol D.7.10.4. write Synopsis: int write(int fd, const void *buf, unsigned int count); Request: Fwrite,fd,bufptr,count Return value: On success, the number of bytes written are returned. Zero indicates nothing was written. On error, -1 is returned. Errors: EBADF fd is not a valid file descriptor or is not open for writing.
  • Page 353 Appendix D. gdb Remote Serial Protocol SEEK_END The offset is set to the size of the file plus offset bytes. Return value: On success, the resulting unsigned offset in bytes from the beginning of the file is returned. Otherwise, a value of -1 is returned.
  • Page 354 Appendix D. gdb Remote Serial Protocol ENOTDIR A component used as a directory in oldpath or new path is not a directory. Or oldpath is a directory and newpath exists but is not a directory. EFAULT oldpathptr or newpathptr are invalid pointer values. EACCES No access to the file or the path of the file.
  • Page 355 Appendix D. gdb Remote Serial Protocol EFAULT pathnameptr is an invalid pointer value. ENAMETOOLONG pathname was too long. ENOENT A directory component in pathname does not exist. ENOTDIR A component of the path is not a directory. EROFS The file is on a read-only filesystem. EINTR The call was interrupted by the user.
  • Page 356 Appendix D. gdb Remote Serial Protocol ENAMETOOLONG pathname was too long. EINTR The call was interrupted by the user. D.7.10.9. gettimeofday Synopsis: int gettimeofday(struct timeval *tv, void *tz); Request: Fgettimeofday,tvptr,tzptr Return value: On success, 0 is returned, -1 otherwise. Errors: EINVAL tz is a non-NULL pointer.
  • Page 357: Protocol Specific Representation Of Datatypes

    Appendix D. gdb Remote Serial Protocol D.7.10.11. system Synopsis: int system(const char *command); Request: Fsystem,commandptr/len Return value: The value returned is -1 on error and the return status of the command otherwise. Only the exit status of the command is returned, which is extracted from the hosts system return value by calling WEXITSTATUS(retval).
  • Page 358 Appendix D. gdb Remote Serial Protocol which is a pointer to data of length 18 bytes at position 0x1aaf. The length is defined as the full string length in bytes, including the trailing null byte. Example: “hello, world” at address 0x123456 is transmitted as 123456/d D.7.11.3.
  • Page 359: Constants

    Appendix D. gdb Remote Serial Protocol The target gets a struct stat of the above representation and is responsible to coerce it to the target representation before continuing. Note that due to size differences between the host and target representation of stat members, these members could eventually get truncated on the target.
  • Page 360 Appendix D. gdb Remote Serial Protocol S_IXOTH D.7.12.3. Errno values All values are given in decimal representation. EPERM ENOENT EINTR EBADF EACCES EFAULT EBUSY EEXIST ENODEV ENOTDIR EISDIR EINVAL ENFILE EMFILE EFBIG ENOSPC ESPIPE EROFS ENAMETOOLONG EUNKNOWN 9999 EUNKNOWN is used as a fallback error value if a host system returns any error value not in the list of supported error numbers.
  • Page 361: File-I/O Examples

    Appendix D. gdb Remote Serial Protocol D.7.13. File-I/O Examples Example sequence of a write call, file descriptor 3, buffer is at target address 0x1234, 6 bytes should be written: Fwrite,3,1234,6 request memory read from target m1234,6 - XXXXXX return "6 bytes written" Example sequence of a read call, file descriptor 3, buffer is at target address 0x1234, 6 bytes should be read: Fread,3,1234,6...
  • Page 362 Appendix D. gdb Remote Serial Protocol...
  • Page 363: The Gdb Agent Expression Mechanism

    Appendix E. The GDB Agent Expression Mechanism In some applications, it is not feasable for the debugger to interrupt the program’s execution long enough for the developer to learn anything helpful about its behavior. If the program’s correctness depends on its real-time behavior, delays introduced by a debugger might cause the program to fail, even when the code itself is correct.
  • Page 364 Appendix E. The GDB Agent Expression Mechanism By the time the bytecode interpreter reaches the end of the expression, the value of the expression should be the only value left on the stack. For tracing applications, bytecodes in the expres- trace sion will have recorded the necessary data, and the value on the stack may be discarded.
  • Page 365: Bytecode Descriptions

    Appendix E. The GDB Agent Expression Mechanism reg 1 Push the value of register 1 (presumably holding ) onto the stack. reg 2 Push the value of register 2 (holding const32 address of z Push the address of onto the stack. ref32 Fetch a 32-bit word from the address at the top of the stack;...
  • Page 366 Appendix E. The GDB Agent Expression Mechanism For the bytecode, there are no stack items given before the =>; this simply means that the const8 bytecode consumes no values from the stack. If a bytecode consumes no values, or produces no values, the list on either side of the =>...
  • Page 367 Appendix E. The GDB Agent Expression Mechanism (0x0e): => log_not Pop an integer from the stack; if it is zero, push the value one; otherwise, push the value zero. (0x0f): => bit_and a&b Pop two integers from the stack, and push their bitwise (0x10): =>...
  • Page 368 Appendix E. The GDB Agent Expression Mechanism If attempting to access memory at would cause a processor exception of some sort, termi- addr nate with an error. (0x1b): => ref_float addr (0x1c): => ref_double addr (0x1d): => ref_long_double addr (0x1e): =>...
  • Page 369: Using Agent Expressions

    Appendix E. The GDB Agent Expression Mechanism ness. The register number is not guaranteed to fall at any particular alignment within the bytecode stream; thus, on machines where fetching a 16-bit on an unaligned address raises an exception, you should fetch the register number one byte at a time. (0x0c): =>...
  • Page 370: Tracing On Symmetrix

    Appendix E. The GDB Agent Expression Mechanism of the agent, without confusing old versions of GDB, and it should contain a version number. It should contain at least the following information: whether floating point is supported • whether is supported •...
  • Page 371 Appendix E. The GDB Agent Expression Mechanism adbg_find_memory_in_frame (f, (char*) 0x8000, &buffer, &size) This would set , set to sixteen, and return buffer 0x1000 size OK_TARGET_RESPONSE since saves sixteen bytes from 0x8000 0x1000 adbg_find_memory_in_frame (f, (char *) 0x8004, &buffer, &size) This would set , set to twelve, and return...
  • Page 372: Rationale

    Appendix E. The GDB Agent Expression Mechanism E.6. Rationale Some of the design decisions apparent above are arguable. What about stack overflow/underflow? GDB should be able to query the target to discover its stack size. Given that information, GDB can determine at translation time whether a given expression will overflow the stack. But this spec isn’t about what kinds of error-checking GDB ought to do.
  • Page 373 Appendix E. The GDB Agent Expression Mechanism pointer will have when GDB generates the bytecode, so it cannot determine whether a particular fetch will be aligned or not. In particular, structure bitfields may be several bytes long, but follow no alignment rules; mem- bers of packed structures are not necessarily aligned either.
  • Page 374 Appendix E. The GDB Agent Expression Mechanism reference. Therefore, it’s okay for it not to consume its arguments; it’s meant for a specific context in which we know exactly what it should do with the stack. If we’re going to have a kludge, it should be an effective kludge.
  • Page 375: Gnu General Public License

    Appendix F. GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright © 1989, 1991 Free Software Foundation, Inc. 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. F.1.
  • Page 376 Appendix F. GNU GENERAL PUBLIC LICENSE means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or trans- lated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you".
  • Page 377 Appendix F. GNU GENERAL PUBLIC LICENSE b. Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange;...
  • Page 378: How To Apply These Terms To Your New Programs

    Appendix F. GNU GENERAL PUBLIC LICENSE author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.
  • Page 379 Appendix F. GNU GENERAL PUBLIC LICENSE To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright"...
  • Page 380 Appendix F. GNU GENERAL PUBLIC LICENSE...
  • Page 381: Gnu Free Documentation License

    Appendix G. GNU Free Documentation License Version 1.1, March 2000 Copyright (C) 2000 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 1.
  • Page 382 Appendix G. GNU Free Documentation License A "Transparent" copy of the Document means a machine-readable copy, represented in a for- mat whose specification is available to the general public, whose contents can be viewed and edited directly and straightforwardly with generic text editors or (for images composed of pix- els) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suit- able for input to text formatters.
  • Page 383 Appendix G. GNU Free Documentation License version of the Document. 5. MODIFICATIONS You may copy and distribute a Modified Version of the Document under the conditions of sec- tions 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and mod- ification of the Modified Version to whoever possesses a copy of it.
  • Page 384 Appendix G. GNU Free Documentation License You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combi- nation all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice.
  • Page 385: Addendum: How To Use This License For Your Documents

    Appendix G. GNU Free Documentation License The Free Software Foundation may publish new, revised versions of the GNU Free Documenta- tion License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft/. Each version of the License is given a distinguishing version number.
  • Page 386 Appendix G. GNU Free Documentation License...
  • Page 387: Index

    Index -break-enable, (refer to Section 26.8 gdb/mi Break- point table commands -break-info, (refer to Section 26.8 gdb/mi Breakpoint table commands packet, (refer to Section D.2 Packets -break-insert, (refer to Section 26.8 gdb/mi Breakpoint "No symbol "foo" in current context", (refer to Sec- table commands tion 10.2 Program variables -break-list, (refer to Section 26.8 gdb/mi Breakpoint...
  • Page 388 Index -exec-finish, (refer to Section 26.10 gdb/mi Program , (refer to Section 4.1.2 Choosing modes control , (refer to Section 4.1.1 Choosing files -exec-interrupt, (refer to Section 26.10 gdb/mi Pro- , (refer to Section 4.1.1 Choosing files -pid gram control , (refer to Section 4.1.2 Choosing modes -exec-next, (refer to Section 26.10 gdb/mi Program , (refer to Section 4.1.2 Choosing modes...
  • Page 389 Index -target-download, (refer to Section 26.15 gdb/mi Tar- , (refer to Section 22.3 Command files .gdbinit get Manipulation Commands sections, (refer to Section 17.2 De- .gnu_debuglink -target-exec-status, (refer to Section 26.15 gdb/mi Tar- bugging Information in Separate Files get Manipulation Commands files, reading symbols from, (refer to Section 17.1 -target-list-available-targets, (refer to Section 26.15 Commands to specify files...
  • Page 390 Index annotations for values, (refer to Section 27.3 Values breakpoint commands for gdb/mi, (refer to Section 26.8 gdb/mi Breakpoint table commands append, (refer to Section 10.14 Copy between memory breakpoint conditions, (refer to Section 7.1.6 Break and a file conditions append data to a file, (refer to Section 10.14 Copy be- breakpoint numbers, (refer to Section 7.1 Breakpoints, tween memory and a file...
  • Page 391 Index compilers, (refer Section 14.4.1.3 clear, (refer to Section 7.1.4 Deleting breakpoints C++expressions clear, and Objective-C, (refer to Section 14.4.2.1 C++ exception handling, (refer to Section 14.4.1.7 Method Names in Commands gdb features for C++ clearing breakpoints, watchpoints, catchpoints, (refer C++ scope resolution, (refer to Section 10.2 Program to Section 7.1.4 Deleting breakpoints variables...
  • Page 392 Index connect (to STDBUG), (refer to Section 20.3.13 Tan- debug formats and C++, (refer to Section 14.4.1.3 dem ST2000 C++expressions console i/o as part of file-i/o, (refer to Section D.7.7 debug links, (refer to Section 17.2 Debugging Infor- Console I/O mation in Separate Files console interpreter, (refer to Chapter 23 Command In- debugger crash, (refer to Section 28.1 Have you found...
  • Page 393 Index dis ( ), (refer to Section 7.1.5 Disabling dump/restore files, (refer to Section 10.14 Copy be- disable breakpoints tween memory and a file disable, (refer to Section 7.1.5 Disabling breakpoints dynamic linking, (refer to Section 17.1 Commands to disable breakpoints, (refer to Section 7.1.5 Disabling specify files breakpoints disable display, (refer to Section 10.6 Automatic dis-...
  • Page 394 Index exception handlers, (refer to Section 7.1.3 Setting file-i/o request packet, (refer to Section D.7.3 The catchpoints request packet exception handlers, how to list, (refer to Section 8.4 find trace snapshot, (refer to Section 12.2.1 tfind Information about a frame finish, (refer to Section 7.2 Continuing and stepping exceptionHandler, (refer to Section 19.5.2 What you flinching, (refer to Section 21.7 Optional warnings...
  • Page 395 Index full symbol tables, listing gdb’s internal, (refer to gnu C++, (refer to Section 14.4.1 C and C++ Chapter 15 Examining the Symbol Table gnu Emacs, (refer to Chapter 25 Using gdb under gnu function-call, (refer to Section 27.4 Frames Emacs functions without line info, and stepping, (refer to , (refer to Section 17.2 De-...
  • Page 396 Index hooks, post-command, (refer to Section 22.2 User- info catch, (refer to Section 8.4 Information about a defined command hooks frame hooks, pre-command, (refer to Section 22.2 User- info classes, (refer to Chapter 15 Examining the Sym- defined command hooks bol Table horizontal-scroll-mode, (refer to Section 29.3.1 Read- info display, (refer to Section 10.6 Automatic display...
  • Page 397 Index info sources, (refer to Chapter 15 Examining the Sym- interrupt, (refer to Section 4.2 Quitting gdb bol Table interrupting remote programs, (refer to Section 19.1 info stack, (refer to Section 8.2 Backtraces Connecting to a remote target info symbol, (refer to Chapter 15 Examining the Sym- interrupting remote targets, (refer to Section 19.5.2 bol Table What you must do for the stub...
  • Page 398 Index layout next, (refer to Section 24.4 TUI specific com- machine instructions, (refer to Section 9.5 Source and mands machine code layout prev, (refer to Section 24.4 TUI specific com- macro define, (refer to Chapter 11 C Preprocessor mands Macros layout regs, (refer to Section 24.4 TUI specific com- macro definition, showing, (refer to Chapter 11 C Pre- mands...
  • Page 399 Index map an overlay, (refer to Section 13.2 Overlay Com- Modula-2 checks, (refer to Section 14.4.3.6 Modula-2 mands type and range checks mapped, (refer to Section 17.1 Commands to specify Modula-2 constants, (refer to Section 14.4.3.2 Built-in files functions and procedures mapped address, (refer to Section 13.1 How Overlays Modula-2 defaults, (refer to Section 14.4.3.4 Modula- Work...
  • Page 400 Index notify output in gdb/mi, (refer to Section 26.4.2 overlays, setting breakpoints in, (refer to Section 13.2 gdb/mi Output Syntax Overlay Commands number representation, (refer to Section 21.5 Num- overload-choice, (refer to Section 27.6 Annotation for bers gdb Input numbers for breakpoints, (refer to Section 7.1 Break- overloaded functions, calling, (refer to Section points, watchpoints, and catchpoints 14.4.1.3 C++expressions...
  • Page 401 Index pre-overload-choice, (refer to Section 27.6 Annotation quoting names, (refer to Chapter 15 Examining the for gdb Input Symbol Table pre-prompt, (refer to Section 27.6 Annotation for gdb Input pre-prompt-for-continue, (refer to Section 27.6 Anno- tation for gdb Input ), (refer to Section 6.2 Starting your program pre-query, (refer to Section 27.6 Annotation for gdb r (SingleKey TUI key), (refer to Section 24.3 TUI Sin- Input...
  • Page 402 Index remote protocol, field separator, (refer to Section D.1 running and debugging Sparclet programs, (refer to Overview Section 20.3.11.4 Running and debugging remote serial debugging summary, (refer to Section running VxWorks tasks, (refer to Section 20.2.1.3 19.5.3 Putting it all together Running tasks remote serial debugging, overview, (refer to Section running, on Sparclet, (refer to Section 20.3.11...
  • Page 403 Index set args, (refer to Section 6.3 Your program’s argu- set disassembly-flavor, (refer to Section 9.5 Source ments and machine code set editing, (refer to Section 21.2 Command editing set auto-solib-add, (refer to Section 17.1 Commands to specify files set endian auto, (refer to Section 18.3 Choosing target byte order set auto-solib-limit, (refer to Section 17.1 Commands set endian big, (refer to Section 18.3 Choosing target...
  • Page 404 Index set print elements, (refer to Section 10.7 Print settings set verbose, (refer to Section 21.7 Optional warnings set print max-symbolic-offset, (refer to Section 10.7 and messages Print settings set width, (refer to Section 21.4 Screen size set print null-stop, (refer to Section 10.7 Print settings set write, (refer to Section 16.6 Patching programs set print object, (refer to Section 10.7 Print settings set_debug_traps, (refer to Section 19.5.1 What the...
  • Page 405 Index show debug serial, (refer to Section 21.8 Optional show print pretty, (refer to Section 10.7 Print settings messages about internal happenings show print sevenbit-strings, (refer to Section 10.7 show debug target, (refer to Section 21.8 Optional Print settings messages about internal happenings show print static-members, (refer to Section 10.7 show debug varobj, (refer to Section 21.8 Optional Print settings...
  • Page 406 Index signal-string-end, (refer to Section 27.10 Running the stop a running trace experiment, (refer to Section Program 12.1.6 Starting and Stopping Trace Experiment signalled, (refer to Section 27.10 Running the Pro- stop reply packets, (refer to Section D.3 Stop Reply gram Packets signals, (refer to Section 7.3 Signals...
  • Page 407 Index target sds, (refer to Section 20.3.8 PowerPC target sh3, with H8/300, (refer to Section 20.3.2 Hi- target, (refer to Chapter 18 Specifying a Debugging tachi H8/300 Target target sh3, with SH, (refer to Section 20.3.10 Hitachi target abug, (refer to Section 20.3.5 M68k target array, (refer to Section 20.3.6 MIPS Embedded target sh3e, with H8/300, (refer to Section 20.3.2 Hi- target byte order, (refer to Section 18.3 Choosing tar-...
  • Page 408 Index trace, (refer to Section 12.1.1 Create and Delete Tra- unlink, file-i/o system call, (refer to Section D.7.10.7 cepoints unlink trace experiment, status of, (refer to Section 12.1.6 unmap an overlay, (refer to Section 13.2 Overlay Starting and Stopping Trace Experiment Commands tracebacks, (refer to Section 8.2 Backtraces unmapped overlays, (refer to Section 13.1 How Over-...
  • Page 409 Index packet, (refer to Section D.2 Packets packet, (refer to Section D.2 Packets w (SingleKey TUI key), (refer to Section 24.3 TUI packet, (refer to Section D.2 Packets Single Key Mode packet, (refer to Section D.2 Packets watch, (refer to Section 7.1.2 Setting watchpoints packet, (refer to Section D.2 Packets watchpoint, (refer to Section 27.10 Running the Pro- packet, (refer to Section D.2 Packets...

Table of Contents