Instruction/ maintenance manual of the product 5992-4701 HP (Hewlett-Packard)
Go to page of 369
Debugging w ith GDB Manual T he GNU S our ce -L e v el Debugger HP P ar t Number : 5 9 9 2 - 4 7 0 1 P ublished: F ebr uary 2009 E dition: 1 9.
© Copyright 2009 Hewlett-P ackard Development Company , L.P . Confidential computer software. V alid license from HP required for possession, use or copying. Consistent with F AR 12.211 and 12.212, Commercial Computer Software, Computer Softw are Documentation, and T echnical Data for Commercial Items are licensed to the U.
T able o f C ont en ts Summary of GDB ........................................................................................................................ 15 F re e So ft w a r e ....................................................................
4 .9 D e b u g g i n g p ro gr a ms w it h mu l t i p l e t h r e ad s................................................................4 6 4 .1 0 D eb ug gi ng pr og r am s wi th m u l t i p l e p r o ce ss es ..........................................
8 .1 1 P ri nt in g F lo at in g P o i n t V al u e s....................................................................................9 9 8 .1 2 F l oa ti ng p oi nt h ar dw ar e .....................................................................
1 3 S pec ify ing a Debugging T arget .............................................................................................. 133 1 3. 1 Ac ti ve t ar ge ts .......................................................................................
1 4. 10 .8 S c e n a r i o s i n me m o r y d e b u g g in g.....................................................................1 7 4 14.10.8.1 Stop when freeing unallocated or deallocated blocks. . . . .. . . . . . . .. . . . . . . .. . . . . . . .174 14.
14.15.2 Support for the info target Co mm an d .....................................................2 01 14.15.3 Support for the dumpcore co m m a n d .............................................................2 0 2 14.15.3.1 Enhancements to the dumpcore co m m a n d .
14.25.3 Support for _ _fpreg da t a ty pe o n IP F.........................................................2 2 2 1 4. 25 .4 S u p p o r t f o r _ Co mp le x v a r i ab le s in H P C ........................................................2 2 2 1 4. 25 .
14.35.3.1 Printing of locals and globals in a stripped module.. . . . .. . . . . . . .. . . . . . . .. . . . . . .. . 240 1 4. 35 .3 .2 Ba ck tr ac e on s t r i p p e d f r a me s..................................................................2 4 0 14.
1 6. 2. 10 M i s c e l l a n eo us c o mm an ds ................................................................................26 5 1 6. 3 X D B d at a f o r m at s an d HP W D B e q u i v al e n t s ..................................................
2 0. 7 Er ro rs .........................................................................................................................3 02 2 0. 8 I n f o r m at io n o n br e a k p o i n t s .........................................................
L ist of T able s 14-1 Memory Debugging Commands in Interactive and Batch Mode. .. . . . . . . .. . . . . . . .. . . . . . . .. . . 177 1 6- 1 I nv oc a t i o n c o m m a n ds ...........................................................................
L ist of Ex amples 14-1 Sample Output for the find co m m a n d ....................................................................1 9 8 1 4- 2 S am pl e Co m m a n d s t o P ri nt Na T R e g i s t e rs ...............................................
Summar y 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 w as doing at the moment it crashed. GDB allows you to do the following: • Load the executable along with any required arguments.
Plea: Additions to this section are particularly welcome. If you or y our friends (or enemies, to be evenhanded) hav e been unfairly omitted from this list, w e would like to add your names! So that they may not regard their many labors as thankless, we particularly thank those who shepherded GDB through major releases: Andrew Cagney (release 5.
Brian Fox is the author of the readline libraries providing command-line editing and command history . Andrew Beers of SUNY Buffalo wrote the language-switching code, the Modula-2 support, and contributed the Languages chapter of this manual. Fred Fish wrote most of the support for Unix System V r4.
18.
1 A Sam ple GDB Ses si on This chapter describes the most common GDB commands with the help of an example. The following topics are discussed: • Loading the Executable • Setting the Display Width .
$ (gdb) m4 HP gdb 3.0 for PA-RISC 1.1 or 2.0 (narrow), HP-UX 11.00. Copyright 1986 - 2001 Free Software Foundation, Inc. Hewlett-Packard Wildebeest 3.0 (based on GDB ) is covered by the GNU General Public License. Type "show copying" to see the conditions to change it and/or distribute copies.
((gdb)) n 882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1]) : nil, 1 .6 St epping in to a subr outine The set_quotes looks like a promising subroutine. W e can go into it by using the command s ( step ) instead of next . step goes to the next line to be executed in any subroutine, so it steps into set_quotes .
((gdb)) p lquote $1 = 0x35d40 "<QUOTE>" ((gdb)) p rquote $2 = 0x35d50 "<UNQUOTE>" 1 .9 L isting S our ce Code lquote and rquote are indeed the new left and right quotes. T o look at some context, we can display ten lines of source surrounding the current line with the l ( list ) command.
((gdb)) c Continuing. define(baz,defn(<QUOTE>foo<UNQUOTE>)) baz 0000 Success! The new quotes now w ork just as well as the default ones. The problem seems to have been just the tw o typos defining the wrong lengths. W e allow m4 to exit by giving it an EOF as input: C-d Program exited normally.
24.
2 Getting In and Out o f GDB This chapter discusses how to start GDB, and exit out of it. The essentials are: • type '(gdb)' to start GDB. • type quit or C-d to exit. 2 . 1 Inv oking GDB Invoke GDB by running the program ( gdb ). Once started, GDB reads commands from the terminal until you tell it to exit.
All options and command-line arguments you give are processed in sequential order . The order makes a difference when the ` -x ' option is used. 2 . 1 . 1 Choosing f iles When GDB starts, it reads any arguments other than options as specifying an executable file and core file (or process ID).
-m , -mapped Warning: this option depends on operating system facilities that are not supported on all systems. If memory-mapped files are available on y our system through the mmap system call, you can use this option to have GDB write the symbols from your program into a reusable file in the current directory .
' -n '). Exit with nonzero status if an error occurs in executing the GDB commands in the command files. Batch mode may be useful for running GDB as a filter , for example to download and run a program on another computer; in order to make this more useful, the message Program exited normally.
print routines so as to allow Epoch to display v alues of expressions in a separate window . -annotate level This option sets the annotation level inside GDB. Its effect is identical to using ` set annotate level ' (see “GDB Annotations” (page 297) ).
' xdb_trans.html ', which is usually installed in the directory /opt/langtools/wdb/doc on HP-UX systems. -interpreter interp Use the interpreter interp for interface with the controlling program or device. This option is meant to be set by programs which communicate with GDB using it as a back end.
type the interrupt character at any time because GDB does not allow it to take effect until a time when it is safe. Y ou can use the detach command to release an attached process or device.
32.
3 GDB Co mmands Y ou 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 ).
GDB fills in the rest of the word ' breakpoints ', since that is the only info subcommand beginning with ' bre ': ((gdb)) info breakpoints Y ou can either press RET at this point, to run the info breakpoints command, or backspace and enter something else, if ' breakpoints ' does not look like the command you expected.
bubble(double,double) bubble(int,int) ((gdb)) b 'bubble( In some cases, GDB can tell that completing a name requires using quotes. When this happens, GDB inserts the quote for you (while completi.
help class Using one of the general help classes as an argument, you can get a list of the individual commands in that class. For example, here is the help display for the class status: ((gdb)) help status Status inquiries.
listings under info and under show in the Index point to all the sub-commands. See ???. info This command (abbreviated i ) is for describing the state of your program.
38.
4 R unning Pr ogr ams Under GDB When you run a program under GDB, y ou must first generate debugging information when you compile it using compiler option cc -g -O .
v ariable substitution) in describing the arguments. On Unix systems, you can control which shell is used with the SHELL environment v ariable. GDB uses the C shell ( /usr/bin/csh ). See “ Arguments T o Y our Program” (page 41) . environment. Y our program inherits its environment from GDB.
program. See “Program Input and Output” (page 43) . W ARN ING! Y ou can redirect input and output, but you cannot use pipes to pass the output of the program you are debugging to another program; if you attempt this, GDB is likely to wind up debugging the wrong program.
programs you run. When debugging, it can be useful to try running your program with a modified environment without having to start GDB over again. show envvar List all the environment variables used by GDB. show paths Display the list of search paths for executables (the PATH environment v ariable).
Y ou can use the string '$cwd' to refer to whatever is the current w orking directory at the time GDB searches the path. If y ou use '.' instead, it refers to the directory where you executed the path command. GDB replaces '.' in the directory argument (with the current path) before adding directory to the search path.
NO TE: • Y ou can redirect your program input and output using shell redirection with the run command. For example, run > outfile starts your program, div erting its output to the file ' outfile '.
NO TE: • T o use attach , your program must be running in an environment which supports processes; for example, attach does not work for programs on bare-board targets that lack an operating system. • Y ou must also have permission to send the process a signal.
On some operating systems, a program cannot be executed outside GDB while you have breakpoints set on it inside GDB. Y ou can use the kill command in this situation to permit running your program outside the debugger .
thread identifier whose form v aries depending on the particular system. For example, on L ynxOS, y ou might see [New process 35 thread 27] when GDB notices a new thread. In contrast, on an SGI system, the systag is simply something like ' process 368 ', with no further qualifier .
show threadverbose Display whether set threadverbose is on or off . Here are commands to get more information about threads: info threads Display a summary of all threads currently in your program. GDB displays for each thread (in this order): 1. the thread number assigned by GDB 2.
threadno is the internal GDB thread number , as shown in the first field of the ' info threads ' display . T o apply a command to all threads, use thread apply all args. Whenever GDB stops y our program, due to a breakpoint or a signal, it automatically selects the thread where that breakpoint or signal happened.
set follow-fork-mode mode Set the debugger response to a program call of fork or vfork . A call to fork or vfork creates a new process. The mode can be: parent The original process is debugged after a fork. The child process runs unimpeded. This is the default.
5 S topp ing and C on tin uing The principal purpose of a debugger is to let you stop y our program before it terminates abnormally or runs into trouble, so that you can inv estigate and determine the reason.
5 . 1 . 1 Setting breakpo ints Breakpoints are set with the break command (abbreviated b ). The debugger convenience v ariable ' $bpnum ' records the number of the breakpoint you hav e set most recently; see “Convenience v ariables” (page 96) , for a discussion of what you can do with convenience v ariables.
does not leave an activ e breakpoint. If y ou use break without an argument in the innermost frame, GDB stops the next time it reaches the current location; this may be useful inside loops. GDB normally ignores breakpoints when it resumes execution, until at least one instruction has been executed.
are used. Delete or disable unused hardw are breakpoints before setting new ones (see “Disabling breakpoints” (page 58) ). See “Break conditions” (page 59) . thbreak args Set a hardware-assisted breakpoint enabled only for one stop. args are the same as for the hbreak command and the breakpoint is set in the same w ay .
marked to be disabled or deleted when hit. Enabled or Disabled Enabled breakpoints are marked with ' y '. ' n ' 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 .
GDB itself sometimes sets breakpoints in your program for special purposes, such as proper handling of longjmp (in C programs). These internal breakpoints are assigned negative numbers, starting with -1; ' info breakpoints ' does not display them.
vfork A call to vfork . This is currently only av ailable for HP-UX. load , load libname The dynamic loading of any shared library , or the loading of the library libname . This is currently only av ailable for HP-UX. unload , unload libname The unloading of any dynamically loaded shared library , or the unloading of the library libname .
5 . 1 . 3 Deleting br eakpo ints It is often necessary to eliminate a breakpoint, watchpoint, or catchpoint once it has done its job and you no longer w ant y our program to stop there. This is called deleting the breakpoint. A breakpoint that has been deleted no longer exists; it is forgotten.
• Enabled once. The breakpoint stops your program, but then becomes disabled. • Enabled for deletion. The breakpoint stops your program, but immediately after it does so it is deleted permanently . A breakpoint set with the tbreak command starts out in this state.
say , to just set a watchpoint on a v ariable name, and specify a condition that tests whether the new v alue is an interesting one. Break conditions can have side effects, and may even call functions in your program.
instead of stopping, it just decrements the ignore count by one and continues. As a result, if the ignore count value is n , the breakpoint does not stop the next n times y our program reaches it. ignore bnum count Set the ignore count of breakpoint number bnum to count .
Y ou can use breakpoint commands to start your program up again. Simply use the continue command, or step , or any other command that resumes execution.
alw ays ' [0] cancel ' and ' [1] all '. T yping 1 sets a breakpoint at each definition of function , and typing 0 aborts the break command without setting any new breakpoints. For example, the following session excerpt shows an attempt to set a breakpoint at the overloaded symbol String::after .
When this message is printed, you need to disable or remove some of the hardw are-assisted breakpoints and w atchpoints, and then continue. 5 .2 Contin uing and st epping Continuing means resuming program execution until your program completes normally .
step Continue running your program until control reaches a different source line, then stop it and return control to GDB. This command is abbreviated s .
until , u Continue running until a source line past the current line, in the current stack frame, is reached. This command is used to av oid single stepping through a loop more than once.
stepi , stepi arg , si Execute one machine instruction, then stop and return to the debugger . It is often useful to do ' display/i $pc ' when stepping by machine instructions. This makes GDB automatically display the next instruction to be executed, each time your program stops.
NO TE: Use caution if you disable all signals from certain processes. Disabling ' SIGTRAP ' in your program may cause y our program to hang. HP-UX uses ' SIGTRAP ' to communicate with the debugger .
pass GDB should allow your program to see this signal; y our program can handle the signal, or else it may terminate if the signal is fatal and not handled. nopass GDB should not allow your program to see this signal. When a signal stops your program, the signal is not visible to the program until you continue.
Whenever y our program stops under GDB for any reason, all threads of execution stop, not just the current thread. This allows y ou to examine the overall state of the program, including switching between threads, without w orrying that things may change underfoot.
6 Ex amining the S tack 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.
6 .2 S tac ks W itho ut f r ame s Some compilers provide a way to compile functions so that they operate without stack frames. (For example, the gcc option ' -fomit-frame-pointer ' generates functions without a frame.) This is occasionally done with heavily used library functions to save the frame setup time.
The names where and info stack (abbreviated info s ) are additional aliases for backtrace . Each line in the backtrace shows the frame number and the function name.
NO TE: • On the SP ARC architecture, frame needs two addresses to select an arbitrary frame: a frame pointer and a stack pointer . • On the MIPS and Alpha architecture, it needs two addresses: a stack pointer and a program counter .
info frame , info f This command prints a verbose description of the selected stack frame, including: • the address of the frame • the address of the next frame down (called by this frame) • the.
76.
7 Ex amining S our ce F iles GDB can print parts of the source code of your program, 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.
The following arguments can be given to the list command: list linespec Print lines centered around the line specified by linespec . list first , last Print lines from first to last . Both arguments must be linespecs. list, last Print lines ending with last .
reverse-search regexp The command ' reverse-search regexp ' checks each line, starting with the one before the last line listed and going backw ard, for a match for the regexp . It lists the line(s) that is found. Y ou can abbreviate this command as rev .
show directories Print the source path and display the directories it contains. If your source path is cluttered with directories that are no longer of interest, GDB can end up detecting the wrong version of the source. T o correct this situation, follow these steps: 1.
The following example shows the disassembly of a range of addresses of HP P A-RISC 2.0 code: ((gdb)) disas 0x32c4 0x32e4 Dump of assembler code from 0x32c4 to 0x32e4: 0x32c4 <main+204>: addil 0,.
82.
8 Ex amining Data The usual w ay to examine data in your program is with the print command (abbreviated p ), or its synonym inspect . It evaluates and prints the v alue of an expression of the language your program is written in (see Chapter 9 (page 101) ).
:: ' :: ' allows you to specify a v ariable in terms of the file or function where it is defined. See “Program v ariables” (page 84) . {type} addr Refers to an object of type type stored at address addr in memory .
This use of ' :: ' is very rarely in conflict with the v ery similar use of the same notation in C++. GDB also supports use of the C++ scope resolution operator in GDB expressions.
p *array@len The left operand of ' @ ' must reside in memory . Array values made with ' @ ' in this w ay behave just like other arrays in terms of subscripting, and are coerced to pointers when used in expressions.
t 2 Print as integer in binary . The letter ' t ' stands for “two” 2 . a Print as an address, both absolute in hexadecimal and as an offset from the nearest preceding symbol.
w W ords (four bytes). This is the initial default. g Giant words (eight bytes). Each time you specify a unit size with x , that size becomes the default unit the next time you use x . (For the ' s ' and ' i ' formats, the unit size is ignored and is normally not written.
av ailable for use in expressions in the conv enience v ariable $_ . The contents of that address, as examined, are available in the conv enience v ariable $__ .
disable display dnums ... Disable the display of item numbers dnums . A disabled display item is not printed automatically , but is not forgotten. It may be enabled again later . enable display dnums ... Enable display of item numbers dnums . It becomes effective once again in auto display of its expression, until you specify otherwise.
set print address off Do not print addresses when displaying their contents. For example, this is the same stack frame displayed with set print address off : ((gdb)) set print addr off ((gdb)) f #0 set_quotes (lq="<<", rq=">>") at input.
If you hav e a pointer and y ou are not sure where it points, try ' set print symbol-filename on '. Then you can determine the name and source file location of the v ariable where it points, using ' p/a pointer '. This interprets the address in symbolic form.
}, meat = 0x54 "Pork" } set print pretty off Cause GDB to print structures in a compact format, like this: $1 = {next = 0x0, flags = {sweet = 1, sour = 1}, meat = 0x54 "Pork"} This is the default format. show print pretty Show which format GDB is using to print structures.
} form; }; struct thing foo = {Tree, {Acorn}}; with set print union on in effect ' p foo ' would print $1 = {it = Tree, form = {tree = Acorn, bug = Cocoon}} and with set print union off in effect it would print $1 = {it = Tree, form = {.
arm Decode using the algorithm in the C++ Annotated Reference Manual . W ARN ING! This setting alone is not sufficient to allow debugging cfront generated executables. GDB would require further enhancement to permit that. If you omit style , y ou will see a list of possible formats.
re-read or discarded (for example with the file or symbol-file commands). When the symbol table changes, the v alue history is discarded, since the v alues may contain pointers back to the types defined in the symbol table. The v alues printed are given history numbers by which y ou can refer to them.
Convenience v ariables are prefixed with '$'. Any name preceded by '$' can be used for a convenience v ariable, unless it is one of the predefined machine-specific register names (see “Registers” (page 98) ). (V alue history references, in contrast, are numbers preceded by '$'.
8. 1 0 R egister s Y ou can refer to machine register contents, in expressions, as variables with names starting with '$'. The names of registers are different for each machine.
Some registers have distinct raw and virtual data formats. This means that the data format in which the register contents are sav ed by the operating system is not the same one that your program normally sees.
100.
9 Using GDB w ith Diff er ent L anguage s Although programming languages generally have common aspects, they are rarely expressed in the same manner . For instance, in ANSI C, dereferencing a pointer p is accomplished by *p , but in Modula-2, it is accomplished by p^ .
' .cxx ', ' .c++ ' ' .f ', ' .F ', ' .f90 ' Fortran source file. GDB does not distinguish between Fortran 77 and Fortran 90 files. ' .s ', ' .S ' Assembler source file. This actually behaves almost like C, but GDB does not skip over function prologues when stepping.
9 .2 Displa ying the language The following commands help you find out which language is the w orking language, and also what language source files were written in.
error 1 + 2.3 The second example fails because the CARDINAL 1 is not type-compatible with the REAL 2.3. For the expressions you use in GDB commands, y ou can tell the GDB type checker to skip checking.
For expressions you use in GDB commands, y ou can tell GDB to treat range errors in one of three w ays: ignore them, alw ays treat them as errors and abandon the expression, or issue w arnings but ev aluate the expression anyway .
9 .4. 1 C and C++ Since C and C++ are so closely related, many features of GDB apply to both languages. Whenever this is the case, we discuss those languages together .
==, != 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.
:: C++ scope resolution operator . Defined on struct , union , and class types. :: Double colons also represent the GDB scope operator (see “Expressions” (page 83) ). Same precedence as :: , above. If an operator is redefined in the user code, GDB usually attempts to invoke the redefined version instead of using the original meaning.
9 .4. 1 .3 C++ e xpr e ssi ons GDB expression handling can interpret most C++ expressions. W ARN ING! GDB can only debug C++ code if you use the proper compiler . T ypically , C++ debugging depends on the use of additional debugging information in the symbol table, and thus requires special support.
references are often used for large structures. The address of a reference v ariable is alw ays shown, unless you hav e specified ' set print address off '. 5. GDB supports the C++ name resolution operator :: ―your expressions can use it just as expressions in y our program do.
Range checking, if turned on, is done on mathematical operations. Array indices are not checked, since they are often used to index a pointer that is not itself an array . 9 .4. 1 .6 GDB and C The set print union and show print union commands apply to the union type.
searches for a function whose signature matches the argument types, using the standard C++ conversion rules (see “C++ expressions” (page 109) , for details). If it cannot find a match, it emits a message. set overload-resolution off Disable overload resolution for C++ expression ev aluation.
integer*1, integer*2, integer*4, integer*8 • allocatable • assumed-size logical*1, logical*2, • assumed-shape logical*4, logical*8 byte , • adjustable real*4, real*8, real*16 • automatic complex*8, complex*16 • explicit-shape character*len, Array elements are displayed in column-major order .
info common <common_block_name> Lists v alues of v ariables in the named common block. Fortran entry points are supported. Y ou can set a break point specifying an entry point name.
1 0 Ex amining the S y mbol T able The commands described in this chapter allow you to inquire about the symbols (names of v ariables, functions, and types) defined in your program. This information is inherent in the text of your program and does not change as y our program executes.
detailed description, instead of just the name of the type. For example, for this v ariable declaration: struct complex {double real; double imag;} v; the two commands giv e this output: ((gdb)) whati.
info functions regexp Print the names and data types of all defined functions whose names contain a match for regular expression regexp . Thus, ' info fun step ' finds all functions whose names include step ; ' info fun ^step ' finds those whose names start with step .
show symbol-reloading Show the current on or off setting. set opaque-type-resolution on T ell GDB to resolve opaque types. An opaque type is a type declared as a pointer to a struct , class , or union ―for example, struct MyType * ―that is used in one source file although the full declaration of struct MyType is in another source file.
1 1 Alt er ing Ex ec utio n Once you think y ou hav e found an error in your program, y ou might w ant to find out for certain whether correcting the apparent error would lead to correct results in the rest of the run. Y ou can find the answer by experiment, using the GDB features for altering execution of the program.
((gdb)) p g $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.
or of local v ariables. For this reason, the jump command requests confirmation if the specified line is not in the function currently executing. Howev er , even bizarre results are predictable if y ou are well acquainted with the machine-language code of y our program.
return , return expression Y ou can cancel execution of a function call with the return command. If you giv e an expression argument, its v alue is used as the return v alue from the function v alue. When you use return , GDB discards the selected stack frame (and all frames within it).
show write Display whether executable files and core files are opened for writing as well as reading. 11.6 P atching programs 123.
124.
1 2 GDB F iles 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 y our program. T o debug a core dump of a previous run, you must also tell GDB the name of the core dump file. 1 2 .
filename means to discard information on the executable file. symbol-file [ filename ] Read symbol table information from file filename. P A TH is searched when necessary . Use the file command to get both symbol table and program to run from the same file.
option with any of the commands that load symbol table information, if you w ant to be sure GDB has the entire symbol table available. If memory-mapped files are available on y our system through the .
T o do this, use the kill command (see “Killing the child process” (page 45) ). add-symbol-file filename address , add-symbol-file The add-symbol-file command reads additional symbol table information from the file filename.
info files , info target info files and info target are synonymous; both commands print the current target (see Chapter 13 (page 133) ), including the names of the executable and core dump files currently in use by GDB, and the files from which symbols were loaded.
show auto-solib-add Display the current autoloading size threshold, in megabytes. 1 2 .2 Spec ifying shar ed libr ary locations On HP-UX, when the shared libraries your program uses are in a different directory than the path specified in the source or object files, specify the correct files to use with one of two environment v ariables.
For example, if you w ant to use /tmp/usr/lib/libsubs.sl and /tmp/usr/share/ lib/libsubs.sl , you can set GDB_SHLIB_ROOT ' to /tmp . Now whenev er GDB encounters a library with the name /usr/lib/libsubs.sl and /usr/share/lib/ libsubs.sl , GDB looks at /tmp/usr/lib/libsubs.
the preceding source line. This is known to occur in the SunOS 4.1.1 (and earlier) C compiler . GDB circumvents the problem by treating the symbol scope block as starting on the previous source line. bad string table offset in symbol n Symbol number n contains a pointer into the string table which is larger than the size of the string table.
1 3 Spec if y ing a Debugging T ar get A target is the execution environment occupied by your program. Often, GDB runs in the same host environment as y our program; in that case, the debugging target is specified as a side effect when you use the file or core commands.
names or host names to connect with, process numbers, and baud rates. The target command does not repeat if you press RET again after executing the command. help target Displays the names of all targets available. T o display targets currently selected, use either info target or info files (see “Commands to specify files” (page 125) ).
target sim Builtin CPU simulator . GDB includes simulators for most architectures. In general,the following commands work: target sim load run Howev er , you cannot assume that a specific memory map, device drivers, or ev en basic I/O is av ailable, although some simulators do provide these.
set endian big Instruct GDB to assume the target is big-endian. s et endian little Instruct GDB to assume the target is little-endian. set endian auto Instruct GDB to use the byte order associated with the executable. show endian Display GDB's current idea of the target byte order .
1 4 HP -UX Co nf igur ation-S pec if i c Inf or mation While nearly all GDB commands are av ailable for all nativ e and cross v ersions of the debugger , there are some exceptions. This chapter describes features, commands and, enhancements av ailable only on HP-UX.
• Serial debugging of a parent and child process. • Support for P arallel Processing limited to pthread parallelism, but not the compiler generated parallelism, for example, with directives. • Implementation of ask mod e for set follow-fork-mode .
• Enhanced info symbol ADDRESS command. The info symbol ADDRESS command has been enhanced to search for a symbol at the given address. Previously , the info symbol command could be used only to search the global namespace. • Enhanced Jav a debugging support.
• Support for ev aluating macros. • Support for printing the execution path entries in the current frame, or thread. • New Command for Searching a Pattern in the Memory Address Space • New Opt.
the standard library routines under libc.so and libdld.so . The following standard libraries are dependencies for runtime checking: unlink() abort() uwx_register_callbacks() atoi() lseek() chdir() ope.
1 4. 3 Suppo rted P latf or ms and Mode s • Supported Platforms HP WDB supports source-lev el debugging of programs written in HP C, HP aC++, and Fortran 90 on Integrity systems running on HP-UX 11i v2 or later and P A- RISC systems running HP-UX 11i v1 and later .
NO TE: HP WDB cannot be attached to a process that is traced by tools which use ttrace, such as Caliper , adb, and tusc. The debugger displays the following error message on attempting to attach to such a process: Attaching to process <pid> failed.
n/a /opt/langtools/ bin $WDB_ROOT/bin librtc.sl location n/a GDB_SERVER $WDB_ROOT/bin None $LIBRTC_SERVER n/a $WDB_ROOT/lib /opt/langtools/ bin NO TE: If y ou define WDB_ROOT or GDB_ROOT but do not create the correct directory structure below it, the debugger may fail.
howev er , may not find source files if the object files are not av ailable. This minimizes or eliminates the need to specify multiple objectdir commands when object files are moved from the compilation directories or when compilation directories are mounted ov er NFS.
The adv antages include: • Y ou do not have to recompile and relink the entire program. • Y ou do not have to reload the program into the debugger . • Y ou can resume execution of the program from the x location. • Y ou can speed up the development cycle.
• Y ou cannot add an alloca() function to a frame that did not previously use alloca(). • New structure fields can be added at the end of a structure object, not in the middle of a structure. New fields are only accessible by the modified files. Old structure fields remain intact; no sw apping of them is permitted.
NO TE: Y ou must rebuild the program after y ou use the fix command because the changes you make are temporarily patched into the executable image. The changes are lost if you load a different executable and are not re ected in the original executable when you exit the debugger .
The problem might be that there is no return for the num function. Y ou can correct this without leaving the debugger . 4. Set a break point at main: (gdb) b main Breakpoint 1 at 0x23f8: file sum.c, line 11. 5. Run the program: (gdb) run Starting program: /tmp/hmc/mysum Breakpoint 1, main () at sum.
10. When you finish with the debugging session, y ou can exit the debugger normally: (gdb) q The following modules in /dev/src/mysum have been fixed: /dev/src/sum.c Remember to remake the program. The debugger message lists the source files that you hav e changed during the debugging session.
3. Y ou can use the following commands for debugging inline functions in HP 9000 systems: step next list backtrace frame <n> info locals info args The following commands are not available for de.
The set inline-debug off command disables the inline debugging feature. Y ou can disable inline debugging by entering this command before attaching the debugger to the application. The set inline-debug inline_bp_all command enables you to set and modify break- points on all instances of a particular inline function.
(gdb) set inline-debug inline_bp_all or $ gdb --inline = inline_bp_all • T o set and modify individual breakpoints on specific instances of inline functions and enable inline debugging, enter either.
- show macro [macro-name] or info macro [macro-name] Displays the macro definition, source file name, and the line number . For example: (gdb) info macro VAR2 Defined at scope.c:21 #define VAR2 201 - macro expand [macro-name] Expands the macro and the parameters in the macro.
The macro debugging features are supported for +objdebug and +noobjdebug compiler options. 1 4.9 .2 Exam ples f or Mac r o D ebugging The following example illustrates the use of the macro debugging: Sample Program: $ cat scope.c 1 2 #include <stdio.
(gdb) b 13 Breakpoint 1 at 0x40007d0:0: file scope.c, line 13 from sc. (gdb) b 23 Breakpoint 2 at 0x40007d0:2: file scope.c, line 23 from sc. (gdb) b 30 Breakpoint 3 at 0x40007e0:0: file scope.c, line 30 from sc. (gdb) r Starting program: sc Breakpoint 1, main () at scope.
Breakpoint 2 at 0x40007d0:2: file scope.c, line 23 from sc1. (gdb) b 30 Breakpoint 3 at 0x40007e0:0: file scope.c, line 30 from sc1. (gdb) r Starting program: sc1 Breakpoint 1, main () at scope.c:13 13 { (gdb) print USED1 100 (gdb) print USED1+10 110 (gdb) info macro USED1 Defined at scope.
For more information on memory debugging with WDB, see the Debugging Dynamic Memory Usage Errors Using HP WDB whitepaper at the HP WDB Documentation webpage at: http://www .
HP WDB offers the following memory-debugging capabilities: • Reports memory leaks • Reports heap allocation profile • Stops program execution if bad writes occur with string operations such as s.
use info heap , the result does not show any allocations. info heap filename W rites heap report output to the specified file. info heap idnumber Produces detailed information on the specified heap allocation including the allocation call stack. show heap-check Displays all current settings for memory checking.
info leaks filename W rites the complete leak report output to the specified file. info leak leaknumber Produces detailed information on the specified leak including the allocation call stack. set heap-check block-size num-bytes Instructs WDB to stop the program whenever it tries to allocate a block larger than num-bytes in size.
and, bcopy . WDB 5.6 and later versions of the debugger also v alidates calls to strcat and strncat . NO TE: HP WDB 6.0 and later versions of the debugger improves performance of memory debugging when the string option is set for 32-bit applications on HP-UX 11i v2 and later on Itanium systems.
for the footer is 16 bytes if this option is not used. If the user specifies a v alue less than 16 for the number of bytes, the debugger ignores it and takes the default of 16 bytes. If the user specifies more than 16 bytes, then the debugger considers the largest and closest 16 byte integral from the user-specified v alue.
The debugger assigns each leak a numeric identifier . 7. T o display a stack trace for a specific leak, use the info leak command and specify the number from the list associated with a leak: (gdb) info leak 2 245 bytes leaked in 8 blocks (10.
frame_count=no_frames (or) set heap-check frame-count <no_frames> Sets the number of frames to be printed for leak context. min_heap_size=block_size (or) set heap-check min-heap-size <block_size> Sets the minimum block size to use for heap reporting.
4. Complete one of the following steps to preload the librtc runtime library: • Set the target application to preload librtc by using the +rtc option for the chatr command. In addition to automatically loading the librtc library , the +rtc option for the chatr command also maps the shared libraries as priv ate.
LD_PRELOAD=/opt/langtools/lib/librtc.sl <executable> – For 64-bit IPF applications, LD_PRELOAD=/opt/langtools/lib/pa20_64/librtc.sl <executable> If LD_PRELOAD and chatr +rtc are used to preload the librtc runtime library , the librtc runtime library is loaded from the path specified by LD_PRELOAD .
has the filename rtcconfig . If user prefers to set this option, it must include the filename. ◦ Incorrect usage: export GDBRTC_CONFIG=./ export GDBRTC_CONFIG=/tmp ◦ Correct usage: export GDBRTC_CONFIG=/tmp/yet_another_config export GDBRTC_CONFIG=/tmp/rtcconfig • BATCH_RTC enables or disables batch memory leak detection.
mem_logfile=stderr[+]filename heap_logfile=stderr[+]filename ◦ Specify config_strings for +check=malloc on Itanium or WDB memory check batch mode on Integrity systems. • RTC_PROCESS_GDBINIT is an optional environment variable used to enable processing of the .
4. Complete one of the following steps: – Map the shared libraries privately using chatr , as follows: chatr +dbg enable <executable> On HP-UX 11i v3 Integrity systems, WDB enables automatic debugging of shared libraries without them being mapped private while attaching to a running program.
2. The rtcconfig file should contain entries such as the following: check_heap=on check_leaks=on check_free=on files=exec1:exec2:exec3 output_dir=/tmp/results 3.
1. Complete one of the following steps to preload the librtc runtime library: – Set the target application to preload librtc by using the +rtc option for the chatr command.In addition to automatically loading the librtc library , the +rtc option for the chatr command also maps the shared libraries as private.
2. Run the program. 3. Start a debugging session as follows: gdb -leaks <executable-name> <process-id> 4. Use info heap and info leaks commands to obtain a memory analysis report of the application. NO TE: From HP WDB 5.7 onw ards, the archiv e v ersion of the run time check library , librtc.
set heap-check min-leak-size num For example, if you use, set heap-check min-leak-size 100 WDB does not collect stack traces for allocations smaller than 100 bytes. HP WDB still reports leaks smaller than this size, but does not include a stack trace.
Syntax: info corruption [<file name>] The run time memory checking must be enabled before using the info corruption command to detect memory corruption. The corruption information is written to a file specified in the .file name argument if provided.
NO TE: Softw are literature names this concept as prematur e free or Reading/writing fr eed memory using a pointer . WDB tracks the dangling pointers and dangling blocks using a modified version of Garbage collection.
T abl e 1 4 - 1 M emory Debugging Commands in Interactive and Batch Mode Batch mode Interactiv e mode Command Description check_heap= [on | off] (or) set heap-check [on | off] set heap-check [on | off.
T abl e 1 4 - 1 M emory Debugging Commands in Interactive and Batch Mode (contin ued) Batch mode Interactiv e mode Command Description Not supported in batch mode set heap-check random-range <num> Specifies the random range to be used by random-range .
show heap-check Displays all current settings for memory checking. 1 4. 1 0. 1 0.2 info heap arena The info heap arena command enables the user to view high level memory usage details of each arena. The info heap arena is not supported in batch mode. This command is av ailable only for applications running on 11i v3 or later .
4. When the program is stopped at a breakpoint, use the info heap command: (gdb) info heap Analyzing heap ...done Actual Heap Usage: Heap Start = 0x40408000 Heap End = 0x4041a900 Heap Size = 76288 bytes Outstanding Allocations: 41558 bytes allocated in 28 blocks No.
set heap-check high-mem-count X_number Stops when brk() v alue has moved X_number of times. Limitations: • This feature assumes that an application has a deterministic memory allocation pattern from one run to another . • The high_mem feature is not supported in batch mode debugging.
1 4. 1 1 .2 Backtr ace Suppo rt for T hr ead D ebugging The following commands are av ailable as backtrace support for thread debugging: bt The bt command provides the stack trace of the current thread that is being executed or the thread that accepts the signal in case of a core file.
• The thread terminates execution, and the resources associated with the terminated thread continues to exist in the application because the thread has not been joined or detached. • The thread uses more than the specified percentage of the stack allocated to the thread.
features are av ailable as options to the set thread-check command. The syntax for the set thread-check command is as follows: set thread check { [on|off]| [option] [on|off] |[option] [num]} The set thread-check [on|off] command enables or disables advanced thread debugging.
uses the same condition variable in multiple calls, by different threads to pthread_cond_wait() or pthread_cond_timedwait() , but specifies different mutexes. The debugger transfers the execution control to the user and prints a w arning message when this condition is detected.
read-write locks that are associated with the thread. The debugger transfers the execution control to the user and prints a warning message when this condition is detected. This situation can result in deadlocks if other threads are w aiting to acquire the locked mutexes or read-write locks.
num-waiters [num] The set thread-check num-waiters [num] command checks if the number of threads w aiting on any pthread object exceeds the specified threshold number [num] . The debugger transfers the execution control to the user and prints a warning message when this condition is detected.
1. Set LD_LIBRAR Y_P A TH to include the appropriate directory , by entering one of the following commands: • For 32 bit IPF applications, LD_LIBRARY_PATH=/opt/langtools/wdb/lib/hpux32 • For 64 bi.
$ chatr +dbg enable ./<executable> (This step is not required on Integrity systems.) T o explicitly preload the librtc runtime library and start the target application, enter one of the following commands: — For 32 bit IPF applications, LD_PRELOAD=/opt/langtools/lib/hpux32/librtc.
NO TE: Use the set frame-count setting in the rtconfig file to control the depth of the stack trace file. This command controls the depth of the call stack collected.
NO TE: The configuration file contains lines of the following form: set thread-check [on|off] | [option] [on|off] | [option] [num] And/Or set frame-count [num] And/Or files=<name of the executable on which the thread checking is to be done> For more information, see “Enabling and Disabling Advanced Thread Debugging Features” (page 183) .
5. Complete one of the following steps to preload the librtc runtime library: • Set the target application to preload librtc by using the +rtc option for the chatr command. In addition to automatically loading the librtc library , the +rtc option for the chatr command also maps the shared libraries as priv ate.
If LD_PRELOAD and chatr +rtc are used to preload the librtc runtime library , the librtc runtime library is loaded from the path specified by LD_PRELOAD . If HP WDB detects any thread error condition during the application run, the error log is output to a file in the current working directory .
Behavior of the +check=thread option can be changed by users by providing their own rtcconfig file. The user specified rtcconfig file can be in the current directory or in a directory specified by the GDBRTC_CONFIG environment variable.
1 4. 1 3 Debugging multiple pr ocesse s ( pr ogr ams with fork and vfork calls) 1 4. 1 3 . 1 Ask mode f or set follow-fork-mode The ask command prompts the user to select betw een parent and child as the debugger response to a program call of fork/vfork .
0x40172b27: (b2) P3lc_gr gr=40 0x40172b29: (61) R3body rlen=33 0x40172b2b: (81) B1label_state label=1 0x40172b2c: (c0) B2epilogue t=44 0x40172b2e: (00) R1prologue rlen=0 0x40172b2f: (00) R1prologue rlen=0 1 4.
+length Specifies the length of the memory address range. This parameter is mandatory when end-address is not specified. expr1, expr2, .... Specifies a v ariable or pattern to be searched. The pattern can be a v ariable, hexadecimal character , a character , or a string v alue.
Ex ample 1 4 - 1 Sampl e Output for the find command $ cat example.c #include <stdio.h> #include <stdlib.h> int main() { char *str; str = (char *) malloc (15); strcpy(str,"hihi-hikh"); return 0; } (gdb) find &str[0], &str[15], "hi" 0x400123e0 0x400123e2 0x400123e5 3 patterns found.
where: &a[0] Specifies the start address of the memory address range. &a[10] Specifies the end address of the memory address range. “el”, 'l' Specifies the pattern.
NO TE: Following are different w ays of representing the /size-char and /max-count parameters: /1b /b1 /b /1 /1 /b where: 1 Specifies that find must display 1 matching pattern. b Specifies that the size of the pattern is 8 bits. 1 4. 1 5 Debugging Cor e F iles 1 4.
the core file to be used if the packcore directory does not contain a core file. If used, this second argument causes a symbolic link to be created in the packcore directory in place of the missing core file. The getcore command can be used to examine a packcore directory which w as previously created by unpackcore.
NO TE: Limitations for the enhanced info target command on corefile are as follows: • The enhanced info target command is not supported when the expanded_node_host_names kernel parameter is set. It is supported only for the default utsname . • The heap segment listed in the memory segment does not contain mmapped memory for the given core file.
T o analyze this core file with HP WDB on HP-UX 11i version 2, y ou must do the following: • When starting from HP WDB command line: (gdb) core-file [core.pid | core-filename] • When starting from shell prompt: $ gdb -core a.out [core.pid | core-filename] 1 4.
For example, (gdb) i ep 4 10 • info exec-path summary Prints the summary information about all the local execution path entries in the current frame. This command displays the total number of branches for the frame, the number of branches executed in this frame in the last iteration, and the last executed branch number .
For more information on this feature, see the following example. 1 4. 1 6.2 Ex am ple Illustr ating Exec u tion P ath R eco v ery The following example illustrates the use of the execution path recov ery feature in HP WDB: Sample Pr ogram: $cat execpath.
(gdb) i ep Local execution path table for main(): 0 0x4000a80:2 (execpath.c:10) (gdb) i gep Global execution path table: G0 0x4000a80:2 main (execpath.c:10) (gdb) n 15 if (c) (gdb) i ep Local execution path table for main(): 0 0x4000a80:2 (execpath.c:10) (gdb) i gep Global execution path table: G0 0x4000a80:2 main (execpath.
1 4. 1 8 In voking GDB Bef or e a Pr ogr am Aborts This -crashdebug option enables GDB to monitor the execution of a process or a program. It invokes GDB when the program execution is about to abort. Once the debugger is invoked, y ou can debug the application using the normal debugger commands.
Abort gdb command line call? (y or n) y #0 main () at ./address_error.c:41 41 fun (count, count*1.1); (gdb) bt #0 main () at ./address_error.c:41 (gdb) quit The program is running.
1 4.2 1 . 3 . 1 Setting breakpo ints in uns tr ipped shar ed libr ary GDB will not be able to put breakpoints using symbolic names(of the symbols not in export list) or line numbers in the stripped modules. GDB will be able to place breakpoints using symbol names in the unstripped shared libraries loaded into the stripped executable.
Setting a breakpoint on a template method with multiple instantiations displays a menu showing all instantiations and the user can choose to set breakpoints on all or any one or none. For example, (gdb) file test Reading symbols from test...done. (gdb) b MyClass::MyMember [0] cancel [1] all [2] MyClass::MyMember(int, int) at test.
1 4.2 2 .2 Setting Defe rr ed Breakpo ints in Shar ed Libr ar y On HP-UX, GDB automatically loads symbol definitions from shared libraries when you use the run command, or when y ou examine a core file. (Before y ou issue the run command, GDB does not understand references to a function in a shared library| unless you are debugging a core file.
T o set the breakpoint you must kill the program and then rerun it so that the dynamic linker maps a copy of the shared library priv ately . There are two w ays to run the program: • Rerun the program under GDB to have the debugger cause dld to map all shared libraries as priv ate, enabling breakpoint debugging.
The -mapshared option is implemented on both P A-RISC and Itanium platforms in HP WDB 5.2. This option is provided in the WDB GUI and HP WDB. The default behavior does not change if the -mapshared option for all shared libraries in processes started under the debugger , or dynamically loaded after an attach, are mapped private.
1 4.2 3. 1 . 1 Pr inting Dec imal f loating poin t constan t (gdb) print <num><df/dd/dl/DF/DD/DL> df, DF - _Decimal32 dd, DD - _Decimal64 dl, DL - _Decimal128 This prints the decimal floating point constant based on the data type. 1 4.2 3.
HP WDB supports: • Ev aluation of expressions with decimal floating point constants and variables. • Setting or assignment of decimal floating point constant or v ariable. • Arithmetic operations such as addition, subtraction, multiplication, division, and negation with decimal floating point constants or variables.
Con v er sio n of type s: GDB handles conversion of data types during assignment, printing, and arithmetic and comparison operation. (gdb) p 1.2df +1.2dd This converts double data type (1.2) to _Decimal64 data type and performs addition operation with _Decimal64 data type (1.
1 4.2 5 Language suppo rt 1 4.2 5 . 1 Enhanced Jav a Debugging Support HP WDB shows stack traces of mixed Jav a, C, and C++ programs. It supports unwinding across Jav a frames and provides an effective w ay to examine stack traces containing mixed language frames ( Jav a and C/C++) of both liv e Jav a processes and core files.
Additional stack unwind features are available starting with SDK 1.4.2. These features fall into three categories: Jav a stack unwind enhancements, Jav a heap support, and Jav a threads support. These additional features are available as part of the Jav a stack unwind enhancements: • V iew Jav a compiled frame inlined methods.
Jav a VM Debugging Co mmands The following commands have been added to enhance Java debugging support: brbacktrace Prints backtrace of mixed Jav a and native frames. Standard backtrace command of GDB has been enhanced to w ork with mixed Jav a and native stack frames.
1 4.2 5 . 1 .3 Ja v a cor e file debugging su pport HP WDB shows stack traces of mixed Jav a, C, and C++ programs for jav a corefile. GDB_JAVA_UNWINDLIB environment v ariable must be set to the path name of the Jav a unwind library as explained above.
2. Attach gdb to the running process: $ gdb -p 23989 HP gdb 5.0 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x. Copyright 1986 - 2001 Free Software Foundation, Inc. Hewlett-Packard Wildebeest 5.0 (based on GDB) is covered by the GNU General Public License.
/* off 453 bits, len 27 bits */ float f; /* off 480 bits, len 32 bits */ 1 4.2 5 . 3 Suppo rt for _ _fpreg data type on IPF WDB internally converts __fpreg data type to long double data type to ev aluate an expression or to print the value of the expression.
Y ou do not need to use fully qualified names to access symbols within a namespace. The debugger can compile a list of namespaces activ e in the scope that y ou are in and, when possible, choose an appropriate symbol.
1 4.2 7 Support for o utput logging The Visual Interface for HP WDB terminal user interface (TUI) mode supports the command, log logfile_name , that saves the content of a session to the specified log file.
where, ARRAY is the name of the array , and its size is 5x5. The first two lines are comments about this file and the array . The third line denotes the array coordinates. From the fourth line, the elements of the array are listed. Note: This feature is not supported for the Fortran array slices.
"Steplast is not meaningful for the current line." For example, (gdb) 4 int k = 10; (gdb) sl ---> alias to "steplast" command error: Steplast is not meaningful for the current line T o execute the steplast command in C++ compiled applications, you must compile the application using the HP aC++ version A.
1 4.2 9 D ebugging optimi z ed code HP WDB supports debugging of optimized code (compiled with both -g and -O) for HP aC++, HP ANSI C and HP WDB for HP Itanium.
The following commands are not affected by the optimization lev el of the program being debugged: • attach • catch • commands • continue • core • delete • define • detach • disable .
1 4.2 9 . 1 Debugging Optimi z ed Code at V ar iou s Optimi z atio n Le vels The following sections describe debugging optimized code support at each optimization level. 1 4.2 9 . 1 . 1 +O0 and +O1 At +O1 level, optimizations that affect the user visible state of a program are avoided.
and later versions provide support to prev ent the debugged program from stopping at instructions that are predicated false. The program execution can be stopped by a softw are breakpoint, a hardw are breakpoint, or an asynchronous signal.
execution pattern and translates only the frequently executed code into native Itanium (R)code at runtime. 1 4. 3 0. 1 Debugging the applicati on using GDB under AR IE S ARIES supports debugging of HP 9000 HP-UX applications on HP-UX 11i Integrity servers using the HP 9000 HP-UX GDB.
identically . The exact behavior shown by HP 9000 GDB under ARIES may differ from that on a HP 9000 HP-UX serv er . • If the debugged process is blocking in a system call, any attempt to get to the GDB command prompt by pressing ctrl-C does not w ork.
1 4. 3 1 Visual In terf ace f or WDB WDB includes an HP-supported V isual Interface for WDB with both graphical and terminal modes. The interface is based on V im 5.7 and WDB. This interface replaces the -tui mode on Itanium-based systems. When you use the interface y ou are actually using vim, which is a vi-compatible editor .
(wdb) quit 1 4. 3 1 .2 Nav igating the Visual In terf ace fo r WDB displa y The Visual Interface for WDB window consists of two areas: • Source pane at the top • Debugger pane at the bottom Y ou c.
Run Resume Stop Up Visual Finish Print Type List Interface for WDB Faq Stop Next Down Prompt Print* Edit Credits Y ou can click the softkey or press a function key on the keyboard to invoke the command. The function keys F1 through F8 correspond to the bottom row of softkeys.
1 4. 3 1 . 5 Using the TUI mode T o start V isual Interface for WDB in terminal user interface (TUI) mode, run Visual Interface for WDB with the command: /opt/langtools/bin/vdb -tui This mode works w ell with hpterm and xterm and fairly well with dtterm and VT100 (telnet) terminals.
1 4. 3 1 .7 Using commands to br ow s e thr ough s our ce f ile s browse. For example, CTRL-B , CTRL-F , CTRL-D , CTRL-U are useful for browsing the debugger window . These commands w ork whether or not you escape to ` vi ' mode. These ` vim ' commands require you to escape to ` vi ' mode.
T o save a session to a file: 1. Right-click an empty region of the source or debugger pane. 2. Choose "Save Session to vdb.pid" from the pop-up menu. The debugger writes the input and output to a file whose name ends in the pid of the debugger .
1 4. 3 5 . 1 Support fo r command line calls in a str ipped e xec ut able on P A-RIS C sy s tems In WDB, to perform command line calls in a shared library without the help of dynamic linker (using end.
1 4.3 5 .2 .2 F or 6 4 -bit appli catio ns T o perform command line calls in a stripped executable, linked with end.o , you need to do the following: • In the +std link mode, GDB supports this feature without any changes. Y ou must export the __wdb_call_dummy symbol as shown in the next line.
1 4. 3 6 Displa y ing the cur r ent block s cope inf or mati on The which command takes a symbol as an argument and prints the information on a given symbol.
242.
1 5 The HP -UX T er minal U ser In te rface By default, GDB runs in line mode. For users who prefer an interface similar (though not identical) to that of the XDB debugger , HP provides a terminal user interface (TUI), which appears when you inv oke the gdb command with the -tui option.
When you execute the program up to the first breakpoint by issuing the command run a right angle bracket (>) points to the current location. So after you issue those commands, the window looks some.
The Command pane is alw ays present. The possible configurations of the other panes are: • Source • Disassembly • Source/Disassembly • Disassembly/Register • Source/Register The layout command (abbreviated la ) enables you to change from one window configuration to another .
1 5 .3 .3 S our ce/Dis ass embl y pane The Source/Disassembly pane appears when you issue the command: la split Y ou can also reach this pane from the Source pane with the XDB command: td The window looks like this: :..................................
|;;; print_average (my_list, first, last); | *> |0x3524 <main+8> addil L'-0x800,%dp,%r1 | |0x3528 <main+12> ldo 0x730(%r1),%r26 | |0x352c <main+16> ldi 9,%r24 | |0x3530 <m.
1 5 .4 C yc ling thr ough the panes Use the commands la next and la prev to move from one pane to another without specifying a window name. If y ou specify la next repeatedly , the order the debugger .
:.........................................................................: :flags 29000041 r1 51a800 rp 7f6ce597 : :r3 7f7f0000 r4 1 r5 7f7f06f4 : :r6 7f7f06fc r7 7f7f0800 r8 7f7f0800 : :r9 40006b10 r10 0 r11 40004b78 : :r12 1 r13 0 r14 0 : :r15 0 r16 40003fb8 r17 4 : :.
(gdb) la split (gdb) la regs (gdb) la src (gdb) la regs (gdb) foc next Focus set to REGS window. (gdb) 1 5 .6 S c r o lling panes T o scroll within a pane, you can use the arrow keys or the P age Up and Pa ge Down keys (on some keyboards these are Prev and Next ).
*>:32 print_average (my_list, first, last); : :33 print_average (my_list, first, last - 3); : :34 } : :35 : :......................................................................: File: average.c Procedure: main Line: 32 pc: 0x3524 (gdb) la regs (gdb) la src (gdb) la regs (gdb) foc next Focus set to REGS window.
winheight [ win_name ] [+ | -] num_lines If you omit win_name , the pane with logical focus is resized. When you increase the height of a pane, the height of the Command pane is decreased by the same amount, and vice versa. The height of any other panes remains unchanged.
1 6 XDB to WDB T r ansiti on Gui de This transition aid is designed for XDB users who are learning WDB, an HP-supported version of the industry-standard GDB debugger . Select one of these lists for a table that shows WDB equiv alents for many common XDB commands and other features.
• “ Assertion control commands” • “Record and playback commands” • “Macro facility commands” • “Signal control commands” • “Miscellaneous commands” 1 6. 1 . 1 Inv ocati on commands By default, HP WDB runs in line mode. T o run it with a terminal user interface similar to that of XDB, use the -tui option.
T abl e 1 6 - 2 Window mode commands (continued) Meaning WDB Equiv alent XDB Command Display general registers gr (with -xdb -tui), display $regs (with -tui) gr Display special registers sr (with -xdb.
T abl e 1 6 -3 File v iew ing commands (continued) Meaning WDB Equiv alent XDB Command List source directory search path (list all directories) ld (with -xdb), show directories ld List all source file.
T abl e 1 6 - 4 Data view ing and modification commands Meaning WDB Equiv alent XDB Command Move view location forw ard or backw ard in source file number lines l (with -xdb) , info args followed by i.
T abl e 1 6 - 4 Data view ing and modification commands (continued) Meaning WDB Equiv alent XDB Command Print address using specified for- mat p/format &expr p expr?format Print static members.
T abl e 1 6 -5 Stack vie wing commands (continued) Meaning WDB Equiv alent XDB Command View procedure one lev el nearer innermost frame of stack (lower number) down up View procedure number lev els ne.
T abl e 1 6 - 7 Job control commands (continued) Meaning WDB Equiv alent XDB Command Go forw ard or back given # lines g {+ | -} lines (with -xdb) , go {+ | -} lines , tb {+ | -} lines followed by jum.
T abl e 1 6 -9 Aux illary breakpoint commands Meaning WDB Equiv alent XDB Command Print any string p "any string" any_string Conditionally execute cmds if expr cmds [else cmds] end if expr {cmds} [{cmds}] Quiet breakpoints Q (with -xdb) , silent (must be first command in a commands list) Q 1 6.
T abl e 1 6 - 1 0 Breakpoint creation commands (continued) Meaning WDB Equiv alent XDB Command Set a class breakpoint at first executable line of all member functions of the instance's class (no base classes).
T abl e 1 6 - 1 1 Ov erall br eakpoint commands (continued) Meaning WDB Equiv alent XDB Command Set a breakpoint count bc number expr (with -xdb), ignorenumber expr (within a commands list) bc number .
1 6.2 .6 Asserti on contr ol commands GDB does not provide the ability to trace by instruction. W atchpoints, howev er , provide similar functionality to xdb assertions.
T abl e 1 6 - 1 3 Mac ro facility commands Meaning WDB Equiv alent XDB Command Define a user-defined command def name [GDB prompts for commands] def name replacement-text T oggle the macro substitutio.
T abl e 1 6 - 1 5 M iscellaneous commands (continued) Meaning WDB Equiv alent XDB Command Invoke a shell ! cmd line (with -xdb), she cmd line ! cmd line Execute command list (group commands) commands [ number ] .
T abl e 1 6 - 1 6 Data for mat commands (continued) Meaning WDB Equiv alent XDB Command Decimal integer d d Long decimal integer d D (1) e Floating-point notation as float No equivalent e e Foating-po.
T abl e 1 6 - 1 6 Data for mat commands (continued) Meaning WDB Equiv alent XDB Command Print in binary t z Print in long binary t Z (1) (1) HP WDB will display data in the size appropriate for the data. It will not extend the length displayed in response to one of the uppercase formchars (for example, O, D, F).
T abl e 1 6 - 1 8 Special language operators Meaning WDB Equiv alent XDB Language Operator Unary operator , address of object Depends on language $addr Unary Boolean operator , execution in procedure No equiv alent $in Unary operator , size of object sizeof $sizeof 1 6.
1 6.7 XDB v ar i able i dentif iers and HP WDB eq ui v alen ts T abl e 1 6 - 20 V ariable Identifiers Meaning WDB Equiv alent XDB V ar iable Identifier Search for var var var Search class for var (bug.
T abl e 1 6 - 2 1 A (continued) Equiv alent WDB Command XDB Command No exact equivalent, but display expr is equiv alent to abc print expr abc cmds am (with -xdb), set height num am No equiv alent apm oldpath [ newpath ] No equiv alent apm "" [ newpath ] 1 6.
T abl e 1 6 - 22 B (continued) Equiv alent WDB Command XDB Command bu [ depth ] (with -xdb). The finish command is equiv alent to the sequence bu, c, db (to continue out of the current routine). bu [ depth ] bx [ depth ] (with -xdb) bx [ depth ] 1 6.8.
1 6.8.4 F thr ough K T abl e 1 6 - 24 F through K Equiv alent WDB Command XDB Command No equiv alent f ["printf-style-fmt"] fr (with -xdb -tui), display $fregs (with -tui) fr g line (with -x.
T abl e 1 6 - 25 L (continued) Equiv alent WDB Command XDB Command show user [string] lm [string] info func [[class]::][string] lo [[class]::][string] info functions lp info func [[class]::]string inf.
T abl e 1 6 - 26 M thr ough P (continued) Equiv alent WDB Command XDB Command No equiv alent pq class:: No equiv alent pq [+ | -][format 1 6.8.7 Q thr ough S T abl e 1 6 - 27 Q thr ough S Equiv alent .
T abl e 1 6 - 28 T (contin ued) Equiv alent WDB Command XDB Command No equiv alent ta No equiv alent tb No equiv alent tc td (with -xdb -tui) td tf (with -xdb -tui), toggle $fregs (with -tui) tf No equiv alent tm frame 0 top No equiv alent tr [@] ts (with -xdb -tui) ts 1 6.
T abl e 1 6 - 29 U through Z (contin ued) Equiv alent WDB Command XDB Command gdb -xdb program -c corefile xdb program corefile gdb -xdb -d dir xdb -d dir gdb -xdb program pid xdb -P pid program (afte.
T abl e 1 6 -30 S ymbols (continued) Equiv alent WDB Command XDB Command Return Return p "any string" "any string" Empty string ; for example, p is the equivalent of p .
T abl e 1 6 -30 S ymbols (continued) Equiv alent WDB Command XDB Command Control-C Control-C # [text] # [ text ] No equiv alent #label 16.8 Alphabetical lists of XDB commands and HP WDB equiv alents 2.
280.
1 7 C on tr olling GDB Y ou can alter the way GDB interacts with y ou by using the set command. For commands controlling how GDB displays data, see “Print settings” (page 90) . Other settings are described here. 1 7 . 1 Setting the GDB Pro mpt GDB indicates its readiness to read a command by printing a string called the prompt.
set editing-mode vi The readline interface uses the .inputrc file to control the settings. set history filename fname Set the name of the GDB command history file to fname . This is the file where GDB reads an initial command history list, and where it writes the command history from this session when it exits.
show commands Display the last ten commands in the command history . show commands n Print ten commands centered on command number n . show commands + Print ten commands just after the commands last printed. 1 7 .4 Setting the GDB Scr een Si z e Certain commands to GDB may produce large amounts of information output to the screen.
set radix 0xa sets the base to decimal. On the other hand, set radix 10 leaves the radix unchanged no matter what it w as. set output-radix base Set the default base for numeric display . Supported choices for base are decimal 8, 10, or 16. base must itself be specified either unambiguously or using the current default radix.
set confirm on Enables confirmation requests (the default). show confirm Displays state of confirmation requests. 1 7 .7 Optional mes sage s abou t inter nal ha ppenings set debug arch T urns on or off display of gdbarch debugging info. The default is off show debug arch Displays the current state of displaying gdbarch debugging information.
show debug v arobj Displays the current state of displaying GDB variable object debugging info. 286 Controlling GDB.
1 8 C anned S eque nces o f C ommands In addition to breakpoint commands (see “Breakpoint command lists” (page 61) ), GDB provides the following two w ays to store sequence of commands for execution as a unit: • user-defined commands • command files 1 8.
are executed repeatedly as long as the expression ev aluates to true. document commandname Document the user-defined command commandname , so that it can be accessed by help. The command commandname must already be defined. This command reads lines of documentation just as define reads the lines of the command definition, ending with end.
end define hook-continue handle SIGLARM pass end Y ou can define a hook for any single-word command in GDB, and not for command aliases; Also you should define a hook for the basic command name, for example, backtrace rather than bt .
• VxW orks (W ind River Systems real-time OS): .vxgdbinit • OS68K (Enea Data Systems real-time OS): .os68gdbinit • ES-1800 (Ericsson T elecom AB M68000 emulator): .esgdbinit Y ou can also request the execution of a command file with the source command: source filename Execute the command file filename .
not entered in the v alue history either . See “Expressions” (page 83) . output/fmt expression Print the v alue of expression in format fmt . Y ou can use the same formats as for print. See “Output formats” (page 86) . printf string , expressions .
292.
1 9 Using GD B 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. T o use this interface, use the command M-x gdb in Emacs. Give the executable file you w ant to debug as an argument.
In the GDB I/O buffer , you can use these special Emacs commands in addition to the standard Shell mode commands: C-h m Describe the features of Emacs' GDB Mode. M-s Execute to another source line, like the GDB step command; also update the display window to show the current file and location.
is formatted using the Emacs function format ; otherwise the number is passed as an argument to the corresponding list element. In any source file, the Emacs command C-x SPC (gdb-break) tells GDB to set a break- point on the source line point is on.
296.
20 GDB Anno tati o ns This chapter describes annotations in GDB. Annotations are designed to interface GDB to graphical user interfaces or other similar programs which w ant to interact with GDB at a relatively high lev el. 20. 1 What is an anno tati on? T o produce annotations, start GDB with the --annotate=2 option.
command history , nor will it affect GDB's notion of which command to repeat if RET is pressed on a line by itself. The server prefix does not affect the recording of v alues into the v alue history; to print a v alue without recording it into the v alue history , use the output command instead of the print command.
^Z^Zfield-value the-value ^Z^Zfield-end where field-name is the name of the field, separator-string is text which separates the name from the v alue for the user's benefit (such as `='), and value-flags and the-value have the same meanings as in a value-history-begin annotation.
• ^Z^Zfunction-call function-call-string where function-call-string is text designed to convey to the user that this frame is associated with a function call made by GDB to a function in the program being debugged.
where source-intro-string separates for the user's benefit the reference from the text which precedes it, filename is the name of the source file, and line-number is the line number within that file (the first line is line 1). If GDB prints some information about where the frame is from (which library , which load segment, etc.
^Z^Zpre-prompt ^Z^Zprompt ^Z^Zpost-prompt The input types are: prompt When GDB is prompting for a command (the main GDB prompt). commands When GDB prompts for a set of commands, like in the commands command . The annotations are repeated for each command which is input.
where header-entry has the same syntax as an entry (see below) but instead of containing data, it 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.
is output. Before the stopped annotation, a variety of annotations describe how the program stopped. ^Z^Zexited exit-status The program exited, and exit-status is the exit status (zero for successful exit, otherwise nonzero). ^Z^Zsignalled The program exited with a signal.
20. 1 2 Annot atio ns W e Migh t W ant in the F u tur e • target-inv alid the target might have changed (registers, heap contents, or execution status).
306.
2 1 T he GDB/MI Int erf ace F unc tio n and purpo se 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.
Notes: • The CLI commands are still handled by the MI interpreter; their output is described below . • The token , when present, is passed back when the command finishes. • Some MI commands accept optional arguments as part of the parameter list.
value const | tuple | list const c-string tuple → "{}" | "{" result ( "," result )* "}" list "[]" | "[" value ( "," value )* &qu.
2 1 . 1 .3 Sim ple e x amples o f GDB/MI inte r acti on This subsection presents several simple examples of interaction using the GDB/MI interface. In these examples, ' -> ' means that the following line is passed to GDB/MI as input, while ' <- ' means the output received from GDB/MI .
2 1 .3 GDB/MI o utput r ecor ds 2 1 .3 . 1 GDB/MI re sult r ecor ds In addition to a number of out-of-band notifications, the response to a GDB/MI command includes one of the following result indications: "^done" [ "," results ] The synchronous operation w as successful, results are the return v alues.
Note the line breaks shown in the examples are here only for readability . They do not appear in the real output. Also note that the commands with a non-av ailable example (N.A.) are not yet implemented. Moti v ati on The motiv ation for this collection of commands.
Ex ample (gdb) -break-insert main ^done,bkpt=number="1",type="breakpoint",disp="keep",enabled="y", addr="0x000100d0",func="main",file="hello.
addr="0x000100d0",func="main",file="hello.c",line="5",cond="1", times="0",ignore="3"}]} (gdb) The -break-delete co mmand S y n opsis -break-delete ( breakpoint )+ Delete the breakpoint (s) whose number(s) are specified in the argument list.
-break-list ^done,BreakpointTable={nr_rows="1",nr_cols="6", hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14&.
Ex ample N.A. The -break-insert co mmand S y n opsis -break-insert [ -t ] [ -h ] [ -r ] [ -c condition ] [ -i ignore-count ] [ -p thread ] [ line | addr ] If specified, line , can be one of: • funct.
^done,bkpt=number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0001072c", file="recursive2.
hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"}, {width="14",alignment="-1",col_name="type",colhdr="Type".
(gdb) -exec-continue ^running (gdb) *stopped,reason="watchpoint-trigger",wpt=number="2",exp="i",value=old="0",new="7" ,thread-id="1",frame=addr="0x000029c4",func="main",args=[],file="hello.
^done,BreakpointTable=nr_rows="1",nr_cols="6",hdr=[width="3",alignment="-1", col_name="number",colhdr="Num",width="14",alignment=&.
GDB command There is no direct mapping from this command to the CLI. Ex ample Disassemble from the current value of $pc to $pc + 20 : (gdb) -data-disassemble -s $pc -e "$pc + 20" -- 0 ^done,.
^done,asm_insns=[ src_and_asm_line={line="31", file="/kwikemart/marge/ezannoni/flathead-dev/devo/gdb/ testsuite/gdb.mi/basics.c",line_asm_insn=[ {address="0x000107bc",fu.
The -data-list-changed-registers C ommand S y n opsis -data-list-changed-registers Display a list of the registers that have changed. GDB command GDB does not have a direct analog for this command; gdbtk has the corresponding command ' gdb_changed_register_list '.
(gdb) -data-list-register-names ^done,register-names=["r0","r1","r2","r3","r4","r5","r6","r7", "r8","r9&q.
^done,register-values=[{number="0",value="0xfe0043c8"}, {number="1",value="0x3fff88"},{number="2",value="0xfffffffe"}, {number="3".
' word-format ' The format to be used to print the memory words. The notation is the same as for GDB print command (see “Output formats” (page 86) ). ' word-size ' The size of each memory word in bytes. ' nr-rows ' The number of rows in the output table.
next-row="0x00001512",prev-row="0x0000150e", next-page="0x00001512",prev-page="0x0000150e",memory=[ {addr="0x00001510",data=["128"]}] (gdb) Read thirty two bytes of memory starting at bytes +16 and format as eight rows of four columns.
The -display-enable co mmand S y n opsis -display-enable number Enable display number . GDB command The corresponding GDB command is ' enable display '. Ex ample N.A. The -display-insert C ommand S y n opsis -display-insert expression Display expression every time the program stops.
Set the GDB working directory . GDB command The corresponding GDB command is ' cd '. Ex ample (gdb) -environment-cd /kwikemart/marge/ezannoni/flathead-dev/devo/gdb ^done (gdb) The -environment-directory co mmand S y n opsis -environment-directory pathdir Add directory pathdir to the beginning of search path for source files.
The -environment-pwd co mmand S y n opsis -environment-pwd Show the current working directory . GDB command The corresponding GDB command is ' pwd '. Ex ample (gdb) -environment-pwd ~Working directory /kwikemart/marge/ezannoni/flathead-dev/devo/gdb.
The -exec-abort co mmand S y n opsis -exec-abort Kill the inferior running program. GDB command The corresponding GDB command is ' kill '. Ex ample N.A. The -exec-arguments co mmand S y n opsis -exec-arguments args Set the inferior program arguments, to be used in the next ' -exec-run '.
The -exec-finish co mmand S y n opsis -exec-finish Asynchronous command. Resumes the execution of the inferior program until the current function is exited. Displays the results returned by the function. GDB command The corresponding GDB command is ' finish '.
Ex ample (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.
Ex ample (gdb) -exec-next-instruction ^running (gdb) *stopped,reason="end-stepping-range",thread- id="1",frame=addr="0x00002a14",func="main",args=[],file="hello.c",line="24" (gdb) The -exec-return co mmand S y n opsis -exec-return Makes current function return immediately .
Ex ample (gdb) -break-insert main ^done,bkpt=number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00002a08", func="main",file="hello.
Regular stepping: -exec-step ^running (gdb) ~"2" ~"3" *stopped,reason="end-stepping-range",thread-id="1",frame=addr="0x000029d8", func="call",args=[name="a",name="b"],file="hello.
greater than the current one is reached. The reason for stopping in this case will be ' location-reached '. GDB command The corresponding GDB command is ' until '.
GDB command The corresponding GDB command is ' exec-file '. Ex ample (gdb) -file-exec-file /kwikemart/marge/ezannoni/TRUNK/mbx/hello.mbx ^done (gdb) The -file-list-exec-sections co mmand S y n opsis -file-list-exec-sections List the sections of the current executable file.
GDB command The corresponding GDB command is info shared . Ex ample N.A. The -file-list-symbol-files co mmand S y n opsis -file-list-symbol-files List symbol files. GDB command The corresponding GDB command is ' info file ' (part of it). Ex ample N.
Exit GDB immediately . GDB command Approximately corresponds to ' quit '. Ex ample (gdb) -gdb-exit The -gdb-set co mmand S y n opsis -gdb-set Set an internal GDB v ariable.
Show version information for GDB. Used mostly in testing. GDB command The corresponding GDB command is ' show version '. Ex ample (gdb) -gdb-version ~GNU gdb 5.
Ex ample For a stack with frame lev els 0 through 11: (gdb) -stack-info-depth ^done,depth="12" (gdb) -stack-info-depth 4 ^done,depth="4" (gdb) -stack-info-depth 12 ^done,depth=&quo.
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="27"}, frame={level="4 ",addr="0x000107e0",func="main", file=".
arguments (inclusive). If the tw o arguments are equal, it shows the single frame at the corresponding level. GDB command The corresponding GDB commands are ' backtrace ' and ' where '.
(gdb) -stack-list-frames 3 3 ^done,stack= [frame={level="3 ",addr="0x000107a4",func="foo", file="recursive2.c",line="14"}] (gdb) The -stack-list-locals co mmand S y n opsis -stack-list-locals print-values Display the local v ariable names for the current frame.
2 1 . 1 0 GDB/MI S ymbol q uery commands The -symbol-info-address co mmand S y n opsis -symbol-info-address symbol Describe where symbol is stored. GDB command The corresponding GDB command is ' info address '. Ex ample N.A. The -symbol-info-file co mmand S y n opsis -symbol-info-file Show the file for the symbol.
The -symbol-info-line co mmand S y n opsis -symbol-info-line Show the core addresses of the code for a source line. GDB command The corresponding GDB command is ' info line '. gdbtk has the ' gdb_get_line ' and ' gdb_get_file ' commands.
List all the type names. GDB command The corresponding commands are ' info types ' in GDB, ' gdb_search ' in gdbtk . Ex ample N.A. The -symbol-list-variables co mmand S y n opsis -symbol-list-variables List all the global and static variable names.
Ex ample N.A. 2 1 . 1 1 GDB/MI T arge t Manipulati on C ommands The -target-attach co mmand S y n opsis -target-attach pid | file Attach to a process pid or a file file outside of GDB. GDB command The corresponding GDB command is ' attach '.
Ex ample (gdb) -target-detach ^done (gdb) The -target-download co mmand S y n opsis -target-download Loads the executable onto the remote target. It prints out an update message ev ery half second, which includes the fields: ' section ' The name of the section.
+download,{section=".text",section-sent="1536",section-size="6668", total-sent="1536",total-size="9880"} +download,{section=".text",section-sent="2048",section-size="6668", total-sent="2048",total-size="9880"} +download,{section=".
Ex ample N.A. The -target-list-available-targets co mmand S y n opsis -target-list-available-targets List the possible targets to connect to. GDB command The corresponding GDB command is ' help target '. Ex ample N.A. The -target-list-current-targets co mmand S y n opsis -target-list-current-targets Describe the current target.
The -target-select co mmand S y n opsis -target-select type parameters ... Connect GDB to the remote target. This command takes two args: ' type ' The type of target, for instance ' async ', ' remote ', and so on. ' parameters ' Device names, host names and the like.
GDB command The equiv alent GDB command is ' info threads '. Ex ample N.A. The -thread-list-ids co mmand S y n opsis -thread-list-ids Produces a list of the currently known GDB thread ids. At the end of the list it also prints the total number of such threads.
^running (gdb) ~"0x7f7f0aec" *stopped,reason="end-stepping-range",thread-id="2",frame=addr="0x00002ca4",func ="printme",args=[name="ip"],file="multithread.
binary , decimal, hexadecimal, octal, and natural. Natural refers to a default format automatically chosen based on the variable type (like decimal for an int , hex for pointers, and so on.
The frame under which the expression should be ev aluated can be specified by frame-addr . A '*' indicates that the current frame should be used.
Returns the number of children of a v ariable object name : numchild= n The -var-list-children co mmand S y n opsis -var-list-children name Returns a list of the children of the specified v ariable ob.
value= value The -var-assign co mmand S y n opsis -var-assign name expression Assigns the v alue of expression to the variable object specified by name .
360.
2 2 Repo rting Bugs in GDB Y our bug reports play an essential role in making GDB reliable. Reporting a bug may help you by bringing a solution to y our 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 .
Keep in mind that the purpose of a bug report is to enable us to x the bug. It may be that the bug has been reported previously , but neither you nor w e can know that unless your bug report is complete and self-contained.
• A description of the envelope of the bug. Often people who encounter a bug spend a lot of time inv estigating which changes to the input file will make the bug go aw ay and which changes will not affect it.
364.
A Inst alling GDB If you obtain GDB (WDB) as part of the HP ANSI C, HP ANSI C++ Developer's Kit for HP-UX Release 11.x, or HP Fortran, you do not hav e to take any special action to build or install GDB. If you obtain GDB (WDB) from an HP w eb site, y ou may download either an swinstall package or a source tree, or both.
gdb-gdb-199991101/mmalloc source for the gnu memory-mapped malloc package The simplest w ay to configure and build GDB is to run configure from the gdb-version-number source directory , which in this example is the gdb-gdb-199991101 directory . First switch to the gdb-version-number source directory if you are not already in it; then run configure.
(GNU make does), running make in each of these directories builds the gdb program specified there. T o build gdb in a separate directory , run configure with the --srcdir option to specify where to find the source. (Y ou also need to specify a path to find configure itself from your w orking directory .
% sh config.sub i386-linux i386-pc-linux-gnu % sh config.sub alpha-linux alpha-unknown-linux-gnu % sh config.sub hp9k700 hppa1.1-hp-hpux % sh config.sub sun4 sparc-sun-sunos4.1.1 % sh config.sub sun3 m68k-sun-sunos4.1.1 % sh config.sub i986v Invalid configuration `i986v': machine `i986v' not recognized config.
--norecursion Configure only the directory level where configure is executed; do not propagate configuration to subdirectories. --target=target Configure GDB for cross-debugging programs running on the specified target. Without this option, GDB is configured to debug programs that run on the same machine (host) as GDB itself.
An important point after buying a device HP (Hewlett-Packard) 5992-4701 (or even before the purchase) is to read its user manual. We should do this for several simple reasons:
If you have not bought HP (Hewlett-Packard) 5992-4701 yet, this is a good time to familiarize yourself with the basic data on the product. First of all view first pages of the manual, you can find above. You should find there the most important technical data HP (Hewlett-Packard) 5992-4701 - thus you can check whether the hardware meets your expectations. When delving into next pages of the user manual, HP (Hewlett-Packard) 5992-4701 you will learn all the available features of the product, as well as information on its operation. The information that you get HP (Hewlett-Packard) 5992-4701 will certainly help you make a decision on the purchase.
If you already are a holder of HP (Hewlett-Packard) 5992-4701, but have not read the manual yet, you should do it for the reasons described above. You will learn then if you properly used the available features, and whether you have not made any mistakes, which can shorten the lifetime HP (Hewlett-Packard) 5992-4701.
However, one of the most important roles played by the user manual is to help in solving problems with HP (Hewlett-Packard) 5992-4701. Almost always you will find there Troubleshooting, which are the most frequently occurring failures and malfunctions of the device HP (Hewlett-Packard) 5992-4701 along with tips on how to solve them. Even if you fail to solve the problem, the manual will show you a further procedure – contact to the customer service center or the nearest service center