HP (Hewlett-Packard) 5992-4701 manual
- Consulta online o descarga el manual de instrucciones
- 369 páginas
- 1.99 mb
Ir a la página of
manuales de instrucciones parecidos
-
Computer Hardware
HP (Hewlett-Packard) XW9300
75 páginas 1.65 mb -
Computer Hardware
HP (Hewlett-Packard) J9051A
2 páginas 0.09 mb -
Computer Hardware
HP (Hewlett-Packard) hp StorageWorks
24 páginas 0.52 mb -
Computer Hardware
HP (Hewlett-Packard) XW
16 páginas 0.44 mb -
Computer Hardware
HP (Hewlett-Packard) B110I
27 páginas 0.38 mb -
Computer Hardware
HP (Hewlett-Packard) FC1242SR
36 páginas 0.37 mb -
Computer Hardware
HP (Hewlett-Packard) 572531-B21
18 páginas 0.83 mb -
Computer Hardware
HP (Hewlett-Packard) J9052A
2 páginas 0.09 mb
Buen manual de instrucciones
Las leyes obligan al vendedor a entregarle al comprador, junto con el producto, el manual de instrucciones HP (Hewlett-Packard) 5992-4701. La falta del manual o facilitar información incorrecta al consumidor constituyen una base de reclamación por no estar de acuerdo el producto con el contrato. Según la ley, está permitido adjuntar un manual de otra forma que no sea en papel, lo cual últimamente es bastante común y los fabricantes nos facilitan un manual gráfico, su versión electrónica HP (Hewlett-Packard) 5992-4701 o vídeos de instrucciones para usuarios. La condición es que tenga una forma legible y entendible.
¿Qué es un manual de instrucciones?
El nombre proviene de la palabra latina “instructio”, es decir, ordenar. Por lo tanto, en un manual HP (Hewlett-Packard) 5992-4701 se puede encontrar la descripción de las etapas de actuación. El propósito de un manual es enseñar, facilitar el encendido o el uso de un dispositivo o la realización de acciones concretas. Un manual de instrucciones también es una fuente de información acerca de un objeto o un servicio, es una pista.
Desafortunadamente pocos usuarios destinan su tiempo a leer manuales HP (Hewlett-Packard) 5992-4701, sin embargo, un buen manual nos permite, no solo conocer una cantidad de funcionalidades adicionales del dispositivo comprado, sino también evitar la mayoría de fallos.
Entonces, ¿qué debe contener el manual de instrucciones perfecto?
Sobre todo, un manual de instrucciones HP (Hewlett-Packard) 5992-4701 debe contener:
- información acerca de las especificaciones técnicas del dispositivo HP (Hewlett-Packard) 5992-4701
- nombre de fabricante y año de fabricación del dispositivo HP (Hewlett-Packard) 5992-4701
- condiciones de uso, configuración y mantenimiento del dispositivo HP (Hewlett-Packard) 5992-4701
- marcas de seguridad y certificados que confirmen su concordancia con determinadas normativas
¿Por qué no leemos los manuales de instrucciones?
Normalmente es por la falta de tiempo y seguridad acerca de las funcionalidades determinadas de los dispositivos comprados. Desafortunadamente la conexión y el encendido de HP (Hewlett-Packard) 5992-4701 no es suficiente. El manual de instrucciones siempre contiene una serie de indicaciones acerca de determinadas funcionalidades, normas de seguridad, consejos de mantenimiento (incluso qué productos usar), fallos eventuales de HP (Hewlett-Packard) 5992-4701 y maneras de solucionar los problemas que puedan ocurrir durante su uso. Al final, en un manual se pueden encontrar los detalles de servicio técnico HP (Hewlett-Packard) en caso de que las soluciones propuestas no hayan funcionado. Actualmente gozan de éxito manuales de instrucciones en forma de animaciones interesantes o vídeo manuales que llegan al usuario mucho mejor que en forma de un folleto. Este tipo de manual ayuda a que el usuario vea el vídeo entero sin saltarse las especificaciones y las descripciones técnicas complicadas de HP (Hewlett-Packard) 5992-4701, como se suele hacer teniendo una versión en papel.
¿Por qué vale la pena leer los manuales de instrucciones?
Sobre todo es en ellos donde encontraremos las respuestas acerca de la construcción, las posibilidades del dispositivo HP (Hewlett-Packard) 5992-4701, el uso de determinados accesorios y una serie de informaciones que permiten aprovechar completamente sus funciones y comodidades.
Tras una compra exitosa de un equipo o un dispositivo, vale la pena dedicar un momento para familiarizarse con cada parte del manual HP (Hewlett-Packard) 5992-4701. Actualmente se preparan y traducen con dedicación, para que no solo sean comprensibles para los usuarios, sino que también cumplan su función básica de información y ayuda.
Índice de manuales de instrucciones
-
Página 1
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[...]
-
Página 2
© 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.S. Government under vend[...]
-
Página 3
T able o f C ont en ts Summary of GDB ........................................................................................................................ 15 F re e So ft w a r e ......................................................................................................................1 5 C on tr ib ut or s to GD B...................[...]
-
Página 4
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 ...........................................................49 5 Stopp ing and Co ntinuing ...................................................[...]
-
Página 5
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 ..............................................................................................9 9 9 Using GDB w ith Diffe r ent L anguages .............................[...]
-
Página 6
1 3 S pec ify ing a Debugging T arget .............................................................................................. 133 1 3. 1 Ac ti ve t ar ge ts .............................................................................................................1 33 1 3. 2 C o m ma nd s fo r m a n ag in g ta r g e t s ...................[...]
-
Página 7
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.10.8.2 Stop when freeing a block if bad writes occurred outside block boundary ..............[...]
-
Página 8
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 ............................................2 0 2 14.15.4 Support for display of[...]
-
Página 9
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 .5 S u p p o r t f o r d e bu gg in g na me sp ac es .............................................[...]
-
Página 10
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.35.3.3 Command line calls to non-stripped library. . . . . .. . . . . . . .. . . . . . . .. . . [...]
-
Página 11
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 6 6 1 6. 4 X D B l oc at io n sy nt ax a nd H P W D B e q u i v al e n t s ............[...]
-
Página 12
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 .......................................................................................3 02 2 0. 9 I n v al i d a t i o n n o t ic es ......................[...]
-
Página 13
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 ...............................................................................................25 4 1 6- 2 W in d o w mo de c om ma nd s......................................[...]
-
Página 14
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 ...............................................................21 4 14 List of Examples[...]
-
Página 15
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. • Stop your program on specified blocks of code. [...]
-
Página 16
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.0);[...]
-
Página 17
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. He also enhanced the command-completion support t[...]
-
Página 18
18[...]
-
Página 19
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 • Setting Breakpoints • Running the Executable under GDB • Stepping to the next line • Stepping into a Subroutine • Examining the Stack • [...]
-
Página 20
$ (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. Type "show warranty" for warranty/s[...]
-
Página 21
((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)) s set_quotes (lq=0x34c[...]
-
Página 22
((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)) l 533 xfree(rquote); [...]
-
Página 23
((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. The message ` Program exited normally .&ap[...]
-
Página 24
24[...]
-
Página 25
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. Y ou can also run ( gdb ) wi[...]
-
Página 26
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). This is the same as if the arguments w ere specifie[...]
-
Página 27
-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 . If the program you are debugging is[...]
-
Página 28
' -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. (which is ordinarily issued whenever a progra[...]
-
Página 29
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) ). Annotation level controls how much information does GDB print together with its prompt, v[...]
-
Página 30
' 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. For example, ' --interpreter=mi &ap[...]
-
Página 31
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. 2 .3 She ll commands If you need to execute occasional shell commands during your debugging session, there is no need to leave or suspend GDB; y ou can just use[...]
-
Página 32
32[...]
-
Página 33
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 ). Y ou can also use the T AB key to get GDB to fill out the rest of a word in a command (or to show you the alternativ es av ailable, if there is more than o[...]
-
Página 34
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. [...]
-
Página 35
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 completing as much as it can) if y ou do not type the quote in the first place: ((gdb)) b bub TAB GDB alters your input line to the following, and rings a bel[...]
-
Página 36
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. List of commands: info -- Generic command for showing things about the program being debugged show -- Generic command for show[...]
-
Página 37
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. For example, you can list the arguments giv en to your program with info args , list the registers currently in use with info registers , or list the breakpoints you hav e set with i[...]
-
Página 38
38[...]
-
Página 39
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 . Y ou may start GDB with its arguments, if any , in an environment of your choice. If you are doing nativ e debugging, y ou may redirect your program's input and output, debug an a[...]
-
Página 40
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. Howev er , you can use the GDB commands set environmen[...]
-
Página 41
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. NO TE: • When you issue the run command, y our program begins to execute [...]
-
Página 42
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). show environment [varname] Print the value of env[...]
-
Página 43
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.[...]
-
Página 44
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 '. • An explicit redirection in run overrides the tty command's effect on the input/output device, but not its effect on the controll[...]
-
Página 45
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. • When you use attach , the debugger finds the program running in the process firs[...]
-
Página 46
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 . The kill command is also useful if you wish to recompile and relink your program, since on many systems it is impossible to modify [...]
-
Página 47
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 . For debugging purposes, GDB associates its own thread num[...]
-
Página 48
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. the target system's thread identifier ( systag ) 3. the curre[...]
-
Página 49
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. GDB alerts you to the con[...]
-
Página 50
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. child The new process is debugged after a fork. The parent process runs unimpeded. show [...]
-
Página 51
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. Inside GDB, your program can stop for several reasons, such as a signal, a breakpoint, or reaching a new line after a GDB command such as ste[...]
-
Página 52
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. Y ou have sev eral w ays t[...]
-
Página 53
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. If it did not do this, you w ould be unable to pro[...]
-
Página 54
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 . Howev er , like the [...]
-
Página 55
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 . If a breakpoint is [...]
-
Página 56
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. Y ou can see these breakpoints with the GDB maintenance command ' maint info breakpoint[...]
-
Página 57
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 . This is c[...]
-
Página 58
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. W ith the clear command you can delete breakpoints acc[...]
-
Página 59
• 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. Y ou can use the following commands to enable or disable breakpoints, watchpoints[...]
-
Página 60
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. This can be useful, for example, to activate functions that log program progress, or to use your own print functions to format speci[...]
-
Página 61
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 . The next count times the breakpoint is reached, your program's execution[...]
-
Página 62
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. Any other commands in the command list, after a command that resumes execution, are ignored. This is because any time you resume execution (ev en with a simple next or step ), you may encounter ano[...]
-
Página 63
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 . W e choose three particular defin[...]
-
Página 64
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 . In contrast, stepping means executing just one more “step” of your program, where “step?[...]
-
Página 65
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 . W ARN ING! If you use the step command while control is within a function that was compiled without debugging information, execution proceeds until control reaches a function that does have debugg[...]
-
Página 66
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. It is like the next command, except that when until encounters a jump, it automatically continues execution until the program counter is greater than the address [...]
-
Página 67
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. See “ Automatic display” (page 89) . An argument is a r[...]
-
Página 68
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 . If you disable all signals from certain processes so that signals will be delivered to the right process, your program may hang whe[...]
-
Página 69
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. Y our program sees the signal then, i[...]
-
Página 70
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. Conversely , whenev er you restart the program, all threads start executing. This is[...]
-
Página 71
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. The information includes the location of the call in y our program, the arguments of the call, and the local v ariables of the fun[...]
-
Página 72
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. GDB has limited facilities fo[...]
-
Página 73
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. The program counter v alue is also shown―unless you use set print address off . The backtrace also shows the source file name and line number , as well as the arguments to the functio[...]
-
Página 74
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 . • On the 29k architecture, it needs three addresses: a register stack pointer , a program counter , and a memor[...]
-
Página 75
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 address of the next frame up (caller of this frame) • the language in which the source code corresponding to this frame is written • the address [...]
-
Página 76
76[...]
-
Página 77
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. Likewise, when you select a stack frame (see “Selecting a frame” (page 73) ),[...]
-
Página 78
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 . list first , Print lines starting with first . list + Print lines just after the lines las[...]
-
Página 79
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 . 7 .3 S pec if y ing s our ce direc tor ies Executable programs sometimes do not reco[...]
-
Página 80
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. Use directory with no arguments to reset the source path to empty . 2. Use dire[...]
-
Página 81
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,dp 0x32c8 <main+208>: ldw 0x22c(sr0,r1),r26 0x32cc <main+212>: ldil 0x3000,r31 0x32d0 <main+216>: ble 0x3f8(sr4,r31) 0x32d4 <main[...]
-
Página 82
82[...]
-
Página 83
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) ). The following forms of print command are supported: print expr , print /f expr expr is an ex[...]
-
Página 84
:: ' :: ' 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 . addr may be any expression whose value is an integer or pointer (but parentheses are required around binary operators, ju[...]
-
Página 85
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. W ARN ING! Occasionally , a local variable may appear to hav e the wrong v alue at certain points in a function just after entry to a new scope, and just befor[...]
-
Página 86
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. Artificial arrays most often appear in expressions via the v alue history (see “V alue history” (page 95) ), af[...]
-
Página 87
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. Y ou can use this format used to discover where (in what function) an unknown address is located: ((gdb)) p/a 0x54320 $3 = 0x54320 <_initialize_vx+396> c R[...]
-
Página 88
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.) addr , starting display address addr is the address wher[...]
-
Página 89
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 $__ . If the x command has a repeat count, the address and contents sav ed are from the last memory unit printed; this is not the same as the last address printed if several units were printed o[...]
-
Página 90
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. display Dis[...]
-
Página 91
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.c:530 530 if (lquote != def_lquote) Y ou can use ' set print address off &ap[...]
-
Página 92
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. For example, here GDB shows that a variable ptt points at another v ar[...]
-
Página 93
}, 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. set print sevenbit-strings on Print using only seven-b[...]
-
Página 94
} 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 = {...}} These settings are of interest when debugging C++ programs: set print demangle , set print demangl[...]
-
Página 95
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. show demangle-style Display the encoding style currently in use fo[...]
-
Página 96
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. These are a range of integers starting with one[...]
-
Página 97
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 '$'. See “V alue history” (page 95) .)[...]
-
Página 98
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. Use info registers to view the names used on your machine. info registers Print the names and values of all registers except floating-point registers (in the sele[...]
-
Página 99
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. For example, the registers of the 68881 floating point coprocessor are always sav ed in “extended” (raw) format, but all C programs expe[...]
-
Página 100
100[...]
-
Página 101
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^ . V alues can also be represented (and displayed) differently . Hex numbers in C a[...]
-
Página 102
' .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. In addition, [...]
-
Página 103
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. show language Display the current w orking language. This is the language y ou can use with commands such as print to build and compute expressions that may involv e v ariables in your [...]
-
Página 104
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; to treat any mismatches as errors and abandon the expression; or to only issue w arnings when type mismatches occur , and ev aluate the expression a[...]
-
Página 105
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 . A range error can result from numerical overflow , from exceeding an array index bound, or when you type a constant tha[...]
-
Página 106
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 . The C++ debugging facilities are jointly implemented by the C++ compiler and GDB. Therefore, to debug your C++ code effectiv ely , you must compile y our C++ programs with a support[...]
-
Página 107
==, != 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. <<, >> left shift, and r[...]
-
Página 108
:: 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 .2[...]
-
Página 109
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. In particular , if y our compiler generates a.out[...]
-
Página 110
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. Since one scope may be defined in another , you can use :: [...]
-
Página 111
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. When set to ' on ', any union that is inside a struct or class is also p[...]
-
Página 112
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. For overloaded functions that are not class member fu[...]
-
Página 113
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 . Use () for array member access (for characte[...]
-
Página 114
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. 9 .4.2 . 3 F ortran spec ial issues Fortran allows main to be a non-main procedure; therefore, to set a breakpoint in the main program, use break _MAIN_ or break [...]
-
Página 115
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. GDB finds it in your program's symbol table, in the file in[...]
-
Página 116
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)) whatis v type = struct complex ((gdb)) ptype v type = struct complex { double real; double imag; } As with whatis , using ptype without an argument refers [...]
-
Página 117
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 . info variables Print the names and data types of all variabl[...]
-
Página 118
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. The defa[...]
-
Página 119
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. For example, you can store ne[...]
-
Página 120
((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. ((gdb)) show g The current BFD target is "=4"[...]
-
Página 121
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. jump * address Resume execution at the instruction at address address . On many[...]
-
Página 122
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). Y ou can think of this as making the discarded frame return pr[...]
-
Página 123
show write Display whether executable files and core files are opened for writing as well as reading. 11.6 P atching programs 123[...]
-
Página 124
124[...]
-
Página 125
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 . 1 Co mmands to spec ify f iles Y ou can specify executable and core dump file names as argumen[...]
-
Página 126
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. symbol-file with no argument clears out GDB information on the symbol table of your program.[...]
-
Página 127
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 mmap system call, you can filename [ -readnow ] [ -mapped ] use another option, `-mapped', to cause GDB to write the symbols for your program int[...]
-
Página 128
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. Y ou would use this command when filename filename address [ -readnow ] has been dynamically loaded (by some other [ -map[...]
-
Página 129
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. Both the commands list all possible targets rather than the current targets. All fil[...]
-
Página 130
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. `GDB_SHLIB_[...]
-
Página 131
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.sl and /tmp/usr/share/ lib/libsubs.sl respectively . 1 2 . 3 Er r ors r [...]
-
Página 132
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. GDB ci[...]
-
Página 133
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. For HP-UX specific information, see undefined [HP-UX T argets], page undefined.[...]
-
Página 134
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) ). help tar[...]
-
Página 135
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. Some configurations may include these targets as well: ta[...]
-
Página 136
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 . Note that these commands merely adjust interpretation of symb[...]
-
Página 137
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. 1 4. 1 Summary of HP Enhancements to GDB WDB provides the following features in add[...]
-
Página 138
• 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 . • Support for setting breakpoints using shared library name. • Support for core file command[...]
-
Página 139
• 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 debugging C++ programs running under Linux Runtime Environment. • Sup[...]
-
Página 140
• 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 Option to Limit the Number of Frames Unwound • Updated Procedure to Process the Initialization File • Enhancement to the info shared Command • Enha[...]
-
Página 141
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() open() dlsym() sprintf() strstr() strcmp() strcat() printf() ctime() pthread_self() dlclose() putenv() memchr() shmctl() strrchr() strchr() dlgetname() r[...]
-
Página 142
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 . • Support for assembly-level debugging HP WDB provides support for assembly-leve[...]
-
Página 143
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. Hint: Check if this process is already being traced by another gdb or other trace tools like ca[...]
-
Página 144
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. 1 4.6 Spec ifying ob j ect f ile direc tor ies GDB enables automatic loading of [...]
-
Página 145
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. T o use this feature, the program must be compiled with the +objdebug option. Fo[...]
-
Página 146
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. NO TE: Fix and Continue is only supported with the most recent versions of HP C and HP[...]
-
Página 147
• 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. • If the redefined function[...]
-
Página 148
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 . 1 4.7 .4 Example F ix and C on tinue se ssi on This example shows how[...]
-
Página 149
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.c:11 11 int num = 10; 6. When the program stops at[...]
-
Página 150
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. NO TE: Y ou must rebuild the program after y ou use the [...]
-
Página 151
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 debugging inline functions in HP 9000 systems: breakpoint info frame disassembly NO TE: Inline debugging commands are not av ailable for inlined templat[...]
-
Página 152
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. It also enables the inline debug[...]
-
Página 153
(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 of the following commands be- fore debugging the application: (gdb) set inline-debug inline_bp_individual or $ gdb --inline = inline_bp_individual ?[...]
-
Página 154
- 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. If there are any parameters in the macro, they are substituted in the mac[...]
-
Página 155
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.h> 3 4 #define USED1 100 5 #define USED2 200 6 #define UNUSED1 0 7 #define UNUSED2 0 8 #define[...]
-
Página 156
(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.c:13 13 { (gdb) print USED1 100 (gdb) print USED1+10 110 (gdb) info macro USE[...]
-
Página 157
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.c:4 #define USED1 100 (gdb) info macro USED2 The macro `USE[...]
-
Página 158
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.com/go/wdb . 1 4. 1 0. 1 When to su spect a me mory leak Y ou should suspect a memory leak in the code when you notice that the system is running out of sw ap space or runnin[...]
-
Página 159
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 strcpy and memcpy • Stops program execution when freeing unallocated or de-allocated blocks • Stops program execution when freeing a block if bad w[...]
-
Página 160
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. set heap-check interval < nn > [...]
-
Página 161
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. set heap-check hea[...]
-
Página 162
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. Howev er , the performance degrades for 64-bit applica[...]
-
Página 163
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. Example: If the user spe[...]
-
Página 164
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.05% of all bytes leaked) These range in size from 26 to 36 bytes and are allocated in strdup () in link_the_[...]
-
Página 165
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. min_leak_size=block_size (or) set heap-check min-leak-size <block_size> Sets the [...]
-
Página 166
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. T o enable or disable the target ap[...]
-
Página 167
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 . NO TE: Batch Mode RTC displays one o[...]
-
Página 168
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. • GDB_SERVER is use[...]
-
Página 169
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 .gdbinit file. Y ou can use the .gdbinit file to specify path settings such as dir , ob[...]
-
Página 170
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. For enabling automatic debugging of shared librar[...]
-
Página 171
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. Set the following environment v ariables as follows: export BATCH_RTC=on 4. Complete one of the following steps: — Use the +rtc option for the chatr command on each of the required execu[...]
-
Página 172
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. T o enable or disable the target appl[...]
-
Página 173
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.a , is not av ailable. Y ou must use the shar[...]
-
Página 174
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. 1 4. 1 0.7 .3 S pec ify ing minimum bloc k si z e The min-heap-size option reports the heap alloca[...]
-
Página 175
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. Otherwise, it is printed to the stdout . NO TE: T urning on bounds checking increases the pro[...]
-
Página 176
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. The enabler for doing this is by retaining all the freed blocks internally within RTC without actually freeing it as long as possibl[...]
-
Página 177
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 oggles heap profiling and detection of leaks, bounds, and double free check_leaks =[on | off] (or) set heap-check leaks [on |off] set heap-check l[...]
-
Página 178
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 . Not supported in batch mode set heap-check interval <num> Specifies the time interval[...]
-
Página 179
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 . 1 4. 1 0. 1 0.3 info [...]
-
Página 180
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. Total bytes Blocks Address Function 0 34567 1 0x40411000 foo() 1 4096 1 0x7bd63000 [...]
-
Página 181
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 T hr ead Debugging Suppo rt HP WDB provides thread-d[...]
-
Página 182
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. thread apply all bt Y ou can use the thread apply all bt comman[...]
-
Página 183
• 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. • The number of threads waiting on any pthread object exceeds the specif[...]
-
Página 184
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. This feature is off by default. The set thread-check [on|off] command must[...]
-
Página 185
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. All threads that concurrently wait on any single condition v ariable mu[...]
-
Página 186
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. thread-exit-no-join-detach [on|off] The set thread-check [...]
-
Página 187
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 4. 1 1 .3 .3 C ommands to v iew inf or mati on on pthr[...]
-
Página 188
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 bit IPF applications, LD_LIBRARY_PATH=/opt/langtools/wdb/lib/hpux64 • For 32 bit P A applications, LD_LIBRARY_PATH=/opt/langtools/wdb/lib • For 64-b[...]
-
Página 189
$ 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.so <executable> — For 64 bit IPF applications, LD_PRE[...]
-
Página 190
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. Larger v alues increase the run time. 1 4. 1 1 .5 . 1 Pr e -r equisite s fo r Batc h mode of T hr ead Debugging The v arious prerequisites for Batch mode of Thread Debugging are as fo[...]
-
Página 191
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) . [...]
-
Página 192
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. T o enable or disable the target ap[...]
-
Página 193
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 . The output file has the following naming convention: [...]
-
Página 194
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. If any thread error condition is detected during the application run, the error log will be output to a file in t[...]
-
Página 195
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 . Based on the user selection, the parent or the child process is debugged. For example, (gdb) s[...]
-
Página 196
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. 1 3 .4 Printing CFM and PF S regist er s On Integrity systems, HP WDB prints Current Frame Marker (CFM) and Previous Frame State (PFS) ar64 [...]
-
Página 197
+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. The character pattern must be enclosed within single quotes. The string[...]
-
Página 198
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. (gdb) find/2 &str[0], &[...]
-
Página 199
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. • Using the start address ( start-address ), length ( +length ) parameter , and a pattern ( expr1 ) find &str[0], +11, "hihi" &str[0] Specifies[...]
-
Página 200
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. 1 5 . 1 Gener ating core f iles with packcore / unpackcore / getcore The contents of[...]
-
Página 201
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. It takes one optional argument, [...]
-
Página 202
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.[...]
-
Página 203
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. 1 5 .4 Support for displa y o f run time ty pe inf ormati on HP WDB enables you to vi[...]
-
Página 204
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 . • info global-exec-path[...]
-
Página 205
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.c #include <stdio.h> #include <string.h> #include <stdlib.h> int main() { int [...]
-
Página 206
(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.c:10) (gdb) n 16 printf([...]
-
Página 207
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. This option enables y ou to debug a liv e process ins[...]
-
Página 208
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. Exit anyway? (y or n) y 1 4.20 Instr uc ti on L e v el S t epping During instruction level stepping with nexti and stepi, WDB prints the assembly instruction along with [...]
-
Página 209
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. 1 4.2 1 .4 Sup[...]
-
Página 210
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.C:14 [3] MyClass::[...]
-
Página 211
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.) Wh[...]
-
Página 212
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. • On P A-RISC systems, use the f[...]
-
Página 213
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 2 .6 Setting b[...]
-
Página 214
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. 1 .2 Printing Dec imal floating point v ar i able (gdb) print/<fmt> <var-name> <fmt[...]
-
Página 215
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. • Comparison operations [...]
-
Página 216
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.2dd) and prints v alue in _Decimal64 type. HP WDB handles exceptions such [...]
-
Página 217
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. This has been impleme[...]
-
Página 218
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. • V iew Jav a int[...]
-
Página 219
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. info frame Prints Jav a frame specific information for a Jav a frame. Standard fr[...]
-
Página 220
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. Following are examples that illustrate the gdb command-line options for inv oking gdb on a core fi[...]
-
Página 221
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.Type "show copying" to see the con- ditions to change it and/or distribute cop[...]
-
Página 222
/* 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. Since long double data type has only 15 bit exponent as opposed to 17 bit exponent of __fpr[...]
-
Página 223
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. The debugger recognizes using declarations, using directiv es, namespace aliases, nested namespaces, and unqualified lookup within a[...]
-
Página 224
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. When you use the log command, the debugger sav es a snapshot of the current session, from the start of the session to the point where y ou issu[...]
-
Página 225
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. 1 4.2 7 .2 Support for F ortran ar r a y sli ces HP [...]
-
Página 226
"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.03.50 or later with th[...]
-
Página 227
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 evaluate the name of a function and hence are affected by the optimization level of the program being debugged (in particular , due to inlining): • break • call ?[...]
-
Página 228
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 • enable * • file • forw • handle * • help * • ignore • kill • load • nexti • path • quit • rev • run • set args, set env, [...]
-
Página 229
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. Line numbers are accurately associated with each machine instru[...]
-
Página 230
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. In the case of optimizations such as if-conversion, the predicated false instructions indicate that an alterna[...]
-
Página 231
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. • Both the GDB and the application run under ARIES. • No chan[...]
-
Página 232
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. The process needs to be killed from a different shell. • ARIES does not provide true emulation[...]
-
Página 233
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 . W ith the interface [...]
-
Página 234
(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 can use the arrow and pagination keys on the keyboard to move the cursor: • P agination keys mov e the cursor in the source window , at the top, abov[...]
-
Página 235
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. The function keys F9 and up correspond to the top row . 1 4. 3 1 . 3 Spec[...]
-
Página 236
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. NO TE: A defect in dtterm may truncate the display of lines that d[...]
-
Página 237
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. For example: `/' Search forw ard `?&apo[...]
-
Página 238
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 . If you sav e the session more than once, the new transactions are appended to the file. 1 4. [...]
-
Página 239
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.o ), you must execute the following command: chatr -B immediate <executable> In addition, modify all the calls to shl_load() to specify BIND_IM[...]
-
Página 240
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. • In the +compat link mode, execute the following co[...]
-
Página 241
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. It prints the following information: • current block scope addresses • line information of the definition of the symbol • filename in which the definition of the symbol occurs The which [...]
-
Página 242
242[...]
-
Página 243
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. Use the -xdb option to enable the use of a number of XDB comma[...]
-
Página 244
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 something like this: |----------------------------------------------------------------------| |27 } | |28 | |29 int main(void) | |30 { | |31 /* Try two te[...]
-
Página 245
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 . NO TE: Y ou can abbreviate any command to its shortest unambiguo[...]
-
Página 246
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: :......................................................................: *>:32 print_average (my_list, first, last); : :33 print_av[...]
-
Página 247
|;;; 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 <main+20> ldi 0,%r25 | |0x3534 <main+24> ldil L'0x3000,%r31 | |----------------------------------------------------------------------| Fil[...]
-
Página 248
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 uses is: • Source ( src ) • Disassembly ( asm ) • Source/Disassembly ( split ) • Source/Register • Disassembly/Register If you inv oked the [...]
-
Página 249
:.........................................................................: :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 : :.........................................................................: *>[...]
-
Página 250
(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 ). Y ou can also use the following commands: {+ | -} [ num_lines ] [ win_name ] V ertica[...]
-
Página 251
*>: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. (gdb) fr #0 main () at average.c[...]
-
Página 252
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. For example, the command wh src +3 increases the size of the source pane, and[...]
-
Página 253
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. Invoke WDB with the command gdb -tui to obtain a terminal user inte[...]
-
Página 254
• “ 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. The following [...]
-
Página 255
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 -tui), display $sregs (with -tui) sr T oggle disassembly mode td (with -xdb -tui) td T oggle float register display precision tf (with -xdb -tui), to[...]
-
Página 256
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 files lf (with -xdb), info sources lf List matching files No equivalent lf [ string ] Repeat previous search fo or rev n Repeat previous search in opposit[...]
-
Página 257
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 info locals l Search source forw ard for [last] string lc [ string ] (with -xdb) , info common string lc [ string ] Search source backw ard for [last] [...]
-
Página 258
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 of class No equivalent p class:: Inquire what language is used show language p $lang Print value of next/previous memory location using format Use x/[...]
-
Página 259
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 nearer innermost frame of stack down number up number Display text for current active procedure or at specified depth on stack V [ depth ] (with -xdb), [...]
-
Página 260
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 jump {+ | -} lines g {+ | -} lines Go forw ard or back 1 line g {+ | -} (with -xdb) , go {+ | -}1, tb {+ | -}1 followed by jump {+ | -}1 g {+ | -} Detach[...]
-
Página 261
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.2 .2 Br eakpoin t cr eation commands The GDB [...]
-
Página 262
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). rb ^ class::* bpc -c class Set a class breakpoint at first ex- ecutableUse rb ^class::* for base classes also line of all member functi[...]
-
Página 263
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 expr Delete breakpoint at current line clear db Delete breakpoint of the given number delete number db number Delete all breakpoints delete db * Suspe[...]
-
Página 264
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. For example, w atchpoints can be: • Enabled (corresponds to aa ) • Disabled (corresponds to da ) • Listed (corresponds to info watch ) • Added (corresponds to x ) WDB does [...]
-
Página 265
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 substitution mechanism No equiv alent tm Remove the macro definition for name def name [follow with empty command list] undef name Remove all macro definitions N[...]
-
Página 266
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 ] ... end { cmd list } Interrupt the program Control-C Control-C A comment # [ text ] # [ text ] Activ ate more (turn on pagination) am (with[...]
-
Página 267
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-point notation as double No equivalent E (1) f floating-point notation as float No equivalent f f floating-point notation as double No equiv alent F (1)[...]
-
Página 268
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). 1 6.4 XDB locati on s y ntax and HP [...]
-
Página 269
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.6 XDB spec ial v ar i able s and HP WDB equi v alen ts GDB does not provide spec[...]
-
Página 270
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: not yet) class:: class:: Search proc for var (static variables only) proc:: var [[class]::]proc:[class::] var Search proc for depth on stack No equi[...]
-
Página 271
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.8.2 B T abl e 1 6 - 22 B Equiv alent WDB Command XDB Command b loc b loc b b ba a[...]
-
Página 272
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. 3 C through D T abl e 1 6 - 23 C through D Equiv alent WDB Command XDB Command c, continue c unti[...]
-
Página 273
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 -xdb), go line, tb line followed by jump line g line No equiv alent g #label g {+ | -}lines (with -xdb), go {+ | -}lines tb {+ | -}lines followed by jum[...]
-
Página 274
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 info addr [[class]::]string lp [[class]::]string No equiv alent lpm lr (with -xdb), info all-reg lr lr string (with -xdb), info reg string lr string No e[...]
-
Página 275
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 WDB Command XDB Command q q Q (with -xdb), silent (must be first command in a commands list) Q r [arguments] r [arguments] R (with -xdb), r R s, si s[...]
-
Página 276
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.8.9 U thr ough Z T abl e 1 6 - 29 U through Z Equiv alent WDB Command XDB Co[...]
-
Página 277
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 (after starting) run < file xdb -i (after starting) run > file xdb -o z number s (with -xdb), handle number stop, handle number nostop z number s z n[...]
-
Página 278
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 . . ( dot ) Return - {+ | -}r (with -xdb -tui) , {+ | -} data (with -tui) {+ | -}r {+ | -}[ number] (with -tui; note that a space is required between + or - and t[...]
-
Página 279
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 279[...]
-
Página 280
280[...]
-
Página 281
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. This string is n[...]
-
Página 282
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. Y ou can access this list through his[...]
-
Página 283
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. T o help you read[...]
-
Página 284
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. show input-radix Displ[...]
-
Página 285
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. set de[...]
-
Página 286
show debug v arobj Displays the current state of displaying GDB variable object debugging info. 286 Controlling GDB[...]
-
Página 287
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. 1 User -def ined commands A user-defined command is a sequence of GDB commands to which[...]
-
Página 288
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. After the[...]
-
Página 289
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 . If an error occurs during the execution of your hook, execution of GDB commands stops and GDB issues a prompt (befo[...]
-
Página 290
• 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 . The lines in a command file are execute[...]
-
Página 291
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 ... Print the v alues of the expressions under the control of string . The expressions are sepa[...]
-
Página 292
292[...]
-
Página 293
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. This command starts GDB as a subprocess of Emacs, with input and output t[...]
-
Página 294
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. M-n Execute to next source line in this function, [...]
-
Página 295
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. If you accidentally delete the source-display buffer , an easy way to get it back is to type the com[...]
-
Página 296
296[...]
-
Página 297
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. Annotations start with a newli[...]
-
Página 298
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. 20. 3 V alues When a v alue[...]
-
Página 299
^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. When printing an array , GDB annotates it as follows: ^Z^Zar[...]
-
Página 300
• ^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. • ^Z^Zsignal-handler-caller signal-handler-caller-string where signal-handler-caller-string is text designed to convey to the user [...]
-
Página 301
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.; currently only[...]
-
Página 302
^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. overload-choice When GDB w ants the user to select between v arious overloaded [...]
-
Página 303
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. Fields may contain trailing whitespace. Each entry consists of: ^[...]
-
Página 304
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. After the ^Z^Zsignalled, the annotation continues: intro-text ^Z^Zsignal-nam[...]
-
Página 305
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). For performance, we might ev entually w ant to hit registers-invalid and all-registers-invalid with greater precision • systematic annotation for set/show parameters (including invalidation not[...]
-
Página 306
306[...]
-
Página 307
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. This chapter is a specification of the GDB/MI interface. It is written in the form of a reference[...]
-
Página 308
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. Each option is identified by a leading `-' (dash) and may be followed by an optional argumen[...]
-
Página 309
value const | tuple | list const c-string tuple → "{}" | "{" result ( "," result )* "}" list "[]" | "[" value ( "," value )* "]" | "[" result ( "," result )* "]" stream-record console-stream-output | target-stream-output | log-stream-outp[...]
-
Página 310
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 . Ev aluate e xpres sio n Here is an ex[...]
-
Página 311
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. "^running" The a[...]
-
Página 312
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. Intr odu cti on A brief introduction to this collection of commands as a whole. Co [...]
-
Página 313
Ex ample (gdb) -break-insert main ^done,bkpt=number="1",type="breakpoint",disp="keep",enabled="y", addr="0x000100d0",func="main",file="hello.c",line="5",times="0"(gdb) -break-after 1 3 ~ ^done (gdb) -break-list ^done,BreakpointTable={nr_rows="1",nr_c[...]
-
Página 314
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. This is obviously reflected in the brea[...]
-
Página 315
-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&q[...]
-
Página 316
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: • function • filename:linenum • filename:function • *address The possible optional parameters of this command are: ' -t ' Insert a temporary [...]
-
Página 317
^done,bkpt=number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0001072c", file="recursive2.c",line="4",times="0" (gdb) -break-insert -t foo ^done,bkpt=number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0001[...]
-
Página 318
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[...]
-
Página 319
(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.c",line="8" (gdb) Setting a w atchpoint on a v ariable local [...]
-
Página 320
^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="D[...]
-
Página 321
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, asm_insns=[ {address="0x000107c0",func-name="main",offset="4", inst="mov 2, %o0"}, {address="0x000107c4&[...]
-
Página 322
^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",func-name="main",offset="0", inst="save %sp, -112, %sp"}]}, src_and_asm_line={line="32", file="/kwikemart/[...]
-
Página 323
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 '. Ex ample On a PPC MBX board: (gdb) -exec-continue ^running (gdb) *stopped,r[...]
-
Página 324
(gdb) -data-list-register-names ^done,register-names=["r0","r1","r2","r3","r4","r5","r6","r7", "r8","r9","r10","r11","r12","r13","r14","r15","r16","r17","r18", [...]
-
Página 325
^done,register-values=[{number="0",value="0xfe0043c8"}, {number="1",value="0x3fff88"},{number="2",value="0xfffffffe"}, {number="3",value="0x0"},{number="4",value="0xa"}, {number="5",value="0x3fff68"},{number="6",value=&q[...]
-
Página 326
' 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. ' nr-cols ' The number of columns in the output tab[...]
-
Página 327
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. Include a string encoding with ' x ' used as[...]
-
Página 328
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. GDB command The corresponding GDB command is ' disp[...]
-
Página 329
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. GDB command T[...]
-
Página 330
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. ^done (gdb) 2 1 .7 GDB/MI progr am contr ol Progr am termination As a result of execution,[...]
-
Página 331
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 '. GDB command The corresponding GDB command[...]
-
Página 332
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 Function returning void . -exec-finish ^running (gdb) @hello from foo [...]
-
Página 333
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.c",line="13"} (gdb) (gdb) -exec-interrupt ^error,msg="mi_cmd_exec_interrupt: Inferior[...]
-
Página 334
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 . Does not execut[...]
-
Página 335
Ex ample (gdb) -break-insert main ^done,bkpt=number="1",type="breakpoint",disp="keep",enabled="y",addr="0x00002a08", func="main",file="hello.c",line="23",times="0" (gdb) -exec-run ^running (gdb) *stopped,reason="breakpoint-hit",bkptno="1",t[...]
-
Página 336
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.c",line="16" (gdb) The -exec-step-instruction co mmand S y n opsis -exe[...]
-
Página 337
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 '. Ex ample (gdb) -exec-until recursive2.c:6 ^running (gdb) x = 55 *stopped,reason="location-reached",thread-id="1",frame=addr="0x00002a24"[...]
-
Página 338
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 GDB command ' info file ' shows, among t[...]
-
Página 339
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.A. The -file-symbol-file co mmand S y n opsis -file-symbol-file file Read symbol table info[...]
-
Página 340
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. GDB command The corresponding GDB command is ' set '. Ex ample (gdb) -gdb-set $foo=3 ^done (gdb) The -gdb-show co mmand S y n opsis -gdb-show Show the curren[...]
-
Página 341
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.2.1 ~Copyright 2000 Free Software Foundation, Inc. ~GDB is free software, covered by the GNU General Public License, and ~you are welcome to change it and/or distribute copies of i[...]
-
Página 342
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="12" (gdb) -stack-info-depth 11 ^done,depth="11" (gdb) -stack-info-depth 13 ^done,depth="12" (gdb) The -s tac k -list-argume[...]
-
Página 343
file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="27"}, frame={level="4 ",addr="0x000107e0",func="main", file="../../../devo/gdb/testsuite/gdb.mi/basics.c",line="32"}] (gdb) -stack-list-arguments 0 ^done, stack-args=[ frame={level="0",args=[]}, frame={level="[...]
-
Página 344
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 '. Ex ample Full stack backtrace: (gdb) -stack-list-frames ^done,stack= [frame={level="0 ",addr="0x0001076c",func="foo&quo[...]
-
Página 345
(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. W ith an argument of 0 prints only the[...]
-
Página 346
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. GDB command There is no [...]
-
Página 347
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. Ex ample N.A. The -symbol-info-symbol co mmand S y n opsis -symbol-info-symbol add[...]
-
Página 348
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. GDB command ' info variables ' in GDB, ' gdb_search ' in gdbt[...]
-
Página 349
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 N.A. The -target-compare-sections co mmand S y n opsis -target-compare-sections [ section[...]
-
Página 350
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. ' section-sent ' The size of what has been sent so far for that sect[...]
-
Página 351
+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=".text",sec[...]
-
Página 352
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. GDB comman[...]
-
Página 353
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. See “Commands for managing targets” (p[...]
-
Página 354
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. GDB command P art of ' info threads ' supplies the same information. [...]
-
Página 355
^running (gdb) ~"0x7f7f0aec" *stopped,reason="end-stepping-range",thread-id="2",frame=addr="0x00002ca4",func ="printme",args=[name="ip"],file="multithread.c",line="9" (gdb) -thread-list-ids ^done,thread-ids=thread-id="2",thread-id="1",number-of-threa[...]
-
Página 356
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 following is the complete set of GDB/MI operations defined to access this functionality: T abl e 2 1 - 1 GDB/MI Operations Description Operation create a [...]
-
Página 357
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. expression is any expression v alid on the current language set (must not begin with a '*'), or one of the following: • ' * addr ', where addr is the address of a memory ce[...]
-
Página 358
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 object: numchild= n ,children={{name= name , numchild= n ,type= type },(repeats N times)} The -var-info-type co mmand S y n opsis -var-info-type name Re[...]
-
Página 359
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 . The object must be ' editable '. The -var-update co mmand S y n opsis -var-update { name | "*"} Update the v alue of the v ariable object name by ev aluating its expression aft[...]
-
Página 360
360[...]
-
Página 361
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 . Bug reports are your contribution to t[...]
-
Página 362
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. Sometimes people giv e a few sketchy facts and ask, Does this ring a bell?" Those bug reports are useless, and we urge ev[...]
-
Página 363
• 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. This is often time consuming and not very useful, because the w ay we will nd the bug is by running a single example under the debugger wit[...]
-
Página 364
364[...]
-
Página 365
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. Most customers will w [...]
-
Página 366
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.[...]
-
Página 367
(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 . If the path to configure w ould be the same a[...]
-
Página 368
% 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.sub is also distributed in th[...]
-
Página 369
--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. There is no convenient[...]