background image

Appendix E. The GDB Agent Expression Mechanism

363

pointer will have when GDB generates the bytecode, so it cannot determine whether a particular

fetch will be aligned or not.
In particular, structure bitfields may be several bytes long, but follow no alignment rules; mem-

bers of packed structures are not necessarily aligned either.
In general, there are many cases where unaligned references occur in correct C code, either at

the programmer’s explicit request, or at the compiler’s discretion. Thus, it is simpler to make the

GDB agent bytecodes work correctly in all circumstances than to make GDB guess in each case

whether the compiler did the usual thing.

Why are there no side-effecting operators?

Because our current client doesn’t want them? That’s a cheap answer. I think the real answer

is that I’m afraid of implementing function calls. We should re-visit this issue after the present

contract is delivered.

Why aren’t the

goto

ops PC-relative?

The interpreter has the base address around anyway for PC bounds checking, and it seemed

simpler.

Why is there only one offset size for the

goto

ops?

Offsets are currently sixteen bits. I’m not happy with this situation either:
Suppose we have multiple branch ops with different offset sizes. As I generate code left-to-right,

all my jumps are forward jumps (there are no loops in expressions), so I never know the target

when I emit the jump opcode. Thus, I have to either always assume the largest offset size, or do

jump relaxation on the code after I generate it, which seems like a big waste of time.
I can imagine a reasonable expression being longer than 256 bytes. I can’t imagine one being

longer than 64k. Thus, we need 16-bit offsets. This kind of reasoning is so bogus, but relaxation

is pathetic.
The other approach would be to generate code right-to-left. Then I’d always know my offset size.

That might be fun.

Where is the function call bytecode?

When we add side-effects, we should add this.

Why does the

reg

bytecode take a 16-bit register number?

Intel’s IA-64 architecture has 128 general-purpose registers, and 128 floating-point registers, and

I’m sure it has some random control registers.

Why do we need

trace

and

trace_quick

?

Because GDB needs to record all the memory contents and registers an expression touches. If

the user wants to evaluate an expression

x-

l

y-

l

z

, the agent must record the values of

x

and

x-

l

y

as well as the value of

x-

l

y-

l

z

.

Don’t the

trace

bytecodes make the interpreter less general?

They do mean that the interpreter contains special-purpose code, but that doesn’t mean the inter-

preter can only be used for that purpose. If an expression doesn’t use the

trace

bytecodes, they

don’t get in its way.

Why doesn’t

trace_quick

consume its arguments the way everything else does?

In general, you do want your operators to consume their arguments; it’s consistent, and generally

reduces the amount of stack rearrangement necessary. However,

trace_quick

is a kludge to

save space; it only exists so we needn’t write

dup const8

SIZE

trace

before every memory

Summary of Contents for ENTERPRISE LINUX 3 - SECURITY GUIDE

Page 1: ...Red Hat Enterprise Linux 3 Debugging with gdb ...

Page 2: ...y later version published by the Free Software Foundation with no Invariant Sections with no Front Cover Texts and with no Back Cover Texts A copy of the license is included in the section entitled GNU Free Documentation License Red Hat Inc is not granting permission to any redistributor to use the Red Hat name Red Hat is a registered trademark and the Red Hat Shadow Man logo RPM and the RPM logo ...

Page 3: ... s working directory 28 6 6 Your program s input and output 28 6 7 Debugging an already running process 29 6 8 Killing the child process 29 6 9 Debugging programs with multiple threads 30 6 10 Debugging programs with multiple processes 32 7 Stopping and Continuing 35 7 1 Breakpoints watchpoints and catchpoints 35 7 1 1 Setting breakpoints 35 7 1 2 Setting watchpoints 38 7 1 3 Setting catchpoints 4...

Page 4: ...Create and Delete Tracepoints 93 12 1 2 Enable and Disable Tracepoints 94 12 1 3 Tracepoint Passcounts 94 12 1 4 Tracepoint Action Lists 95 12 1 5 Listing Tracepoints 96 12 1 6 Starting and Stopping Trace Experiment 96 12 2 Using the collected data 97 12 2 1 tfind n 97 12 2 2 tdump 99 12 2 3 save tracepoints filename 100 12 3 Convenience Variables for Tracepoints 100 13 Debugging Programs That Use...

Page 5: ...153 19 1 Connecting to a remote target 153 19 2 Using the gdbserverprogram 154 19 3 Using the gdbserve nlmprogram 155 19 4 Remote configuration 155 19 5 Implementing a remote stub 156 19 5 1 What the stub can do for you 157 19 5 2 What you must do for the stub 157 19 5 3 Putting it all together 158 20 Configuration Specific Information 161 20 1 Native 161 20 1 1 HP UX 161 20 1 2 SVR4 process infor...

Page 6: ...variables 201 25 Using gdb under gnu Emacs 203 26 The gdb mi Interface 207 26 1 Function and Purpose 207 26 2 Notation and Terminology 207 26 3 Acknowledgments 207 26 4 gdb mi Command Syntax 207 26 4 1 gdb mi Input Syntax 207 26 4 2 gdb mi Output Syntax 208 26 4 3 Simple Examples of gdb mi Interaction 210 26 5 gdb mi Compatibility with CLI 211 26 6 gdb mi Output Records 211 26 6 1 gdb mi Result Re...

Page 7: ...and 238 26 11 6 The exec nextCommand 239 26 11 7 The exec next instructionCommand 239 26 11 8 The exec returnCommand 240 26 11 9 The exec runCommand 241 26 11 10 The exec show argumentsCommand 242 26 11 11 The exec stepCommand 242 26 11 12 The exec step instructionCommand 243 26 11 13 The exec untilCommand 243 26 11 14 The file exec and symbolsCommand 244 26 11 15 The file exec fileCommand 245 26 ...

Page 8: ...15 9 The target list parametersCommand 266 26 15 10 The target selectCommand 266 26 16 gdb mi Thread Commands 267 26 16 1 The thread infoCommand 267 26 16 2 The thread list all threadsCommand 268 26 16 3 The thread list idsCommand 268 26 16 4 The thread selectCommand 269 26 17 gdb mi Tracepoint Commands 270 26 18 gdb mi Variable Objects 270 26 18 1 Motivation for Variable Objects in gdb mi 270 26 ...

Page 9: ... 4 2 Commands For Manipulating The History 302 29 4 3 Commands For Changing Text 303 29 4 4 Killing And Yanking 304 29 4 5 Specifying Numeric Arguments 305 29 4 6 Letting Readline Type For You 305 29 4 7 Keyboard Macros 306 29 4 8 Some Miscellaneous Commands 306 29 5 Readline vi Mode 308 30 Using History Interactively 309 30 1 History Expansion 309 30 1 1 Event Designators 309 30 1 2 Word Designat...

Page 10: ...3 File I O Examples 350 E The GDB Agent Expression Mechanism 353 E 1 General Bytecode Design 353 E 2 Bytecode Descriptions 355 E 3 Using Agent Expressions 359 E 4 Varying Target Capabilities 359 E 5 Tracing on Symmetrix 360 E 6 Rationale 361 F GNU GENERAL PUBLIC LICENSE 365 F 1 Preamble 365 F 2 How to Apply These Terms to Your New Programs 368 G GNU Free Documentation License 371 G 1 ADDENDUM How ...

Page 11: ...Chapter 1 Debugging with gdb This file describes gdb the gnu symbolic debugger This is the Ninth Edition for gdb Version 2003 07 22 cvs Copyright C 1988 2003 Free Software Foundation Inc ...

Page 12: ...2 Chapter 1 Debugging with gdb ...

Page 13: ...ng either the Apple NeXT or the GNU Objective C runtime 2 1 Free software gdb is free software protected by the gnu General Public License GPL The GPL gives you the free dom to copy or adapt a licensed program but every person getting a copy also gets with it the freedom to modify that copy which means that they must get access to the source code and the freedom to distribute further copies Typica...

Page 14: ...t of the manual and then distribute the result in all the usual media through all the usual channels Otherwise the restrictions obstruct the use of the manual it is not free and we need another manual to replace it Please spread the word about this issue Our community continues to lose manuals to proprietary publishing If we spread the word that free software needs free reference manuals and free ...

Page 15: ...contributed Sun 386i support Chris Hanson improved the HP9000 support Noboyuki Hikichi and Tomoyuki Hasei con tributed Sony News OS 3 support David Johnson contributed Encore Umax support Jyrki Kuop pala contributed Altos 3068 support Jeff Law contributed HP PA and SOM support Keith Packard contributed NS32K support Doug Rabson contributed Acorn Risc Machine support Bob Rusk con tributed Harris Ni...

Page 16: ...oject Robert Hoehne made significant contribu tions to the DJGPP port Cygnus Solutions has sponsored gdb maintenance and much of its development since 1991 Cygnus engineers who have worked on gdb fulltime include Mark Alexander Jim Blandy Per Bothner Kevin Buettner Edith Epstein Chris Faylor Fred Fish Martin Hunt Jim Ingham John Gilmore Stu Gross man Kung Hsu Jim Kingdon John Metzler Fernando Nass...

Page 17: ... cd gnu m4 m4 define foo 0000 foo 0000 define bar defn foo bar 0000 changequote QUOTE UNQUOTE define baz defn QUOTE foo UNQUOTE baz C d m4 End of input 0 fatal error EOF in string Let us use gdb to try to see what is going on gdb m4 gdb is free software and you are welcome to distribute copies of it under certain conditions type show copying to see the conditions There is absolutely no warranty fo...

Page 18: ...t_quotes argc 2 TOKEN_DATA_TEXT argv 1 nil set_quotes looks like a promising subroutine We 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 0x34c78 QUOTE rq 0x34c88 UNQUOTE at input c 530 530 if lquote def_lquote The display that shows the subroutine where m4 is now suspended and i...

Page 19: ...quote and rquote to see if they are in fact the new left and right quotes we specified We use the command p print to see their values gdb p lquote 1 0x35d40 QUOTE gdb p rquote 2 0x35d50 UNQUOTE lquote and rquote are indeed the new left and right quotes To 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 534 535 lquo...

Page 20: ... enough to fix the problem of using the new quotes with the m4 built in defn We can allow m4 to continue executing with the c continue command and then try the example that caused trouble initially gdb c Continuing define baz defn QUOTE foo UNQUOTE baz 0000 Success The new quotes now work just as well as the default ones The problem seems to have been just the two typos defining the wrong lengths ...

Page 21: ...ed gdb program core You can instead specify a process ID as a second argument if you want to debug a running process gdb program 1234 would attach gdb to process 1234 unless you also have a file named 1234 gdb does check for a core file first Taking advantage of the second command line argument requires a fairly complete operating system when you use gdb as a remote debugger attached to a bare boa...

Page 22: ...llowed by that argument If the second argument begins with a decimal digit gdb will first attempt to attach to it as a process and if that fails attempt to open it as a corefile If you have a corefile whose name begins with a digit you can prevent gdb from treating it as a pid by prefixing it with eg 12345 If gdb has not been configured to included core file support such as for most embedded targe...

Page 23: ...rom it rather than reading the symbol table from the executable program The syms file is specific to the host machine where gdb is run It holds an exact image of the internal gdb symbol table It cannot be shared across multiple host platforms r readnow Read each symbol file s entire symbol table immediately rather than the default which is to read it incrementally as it is needed This makes startu...

Page 24: ... directory as its working directory instead of the current directory fullname f gnu Emacs sets this option when it runs gdb as a subprocess It tells gdb to output the full file name and line number in a standard recognizable fashion each time a stack frame is displayed which includes each time your program stops This recognizable format looks like two 032 characters followed by the file name line ...

Page 25: ...input and output tui Activate the Terminal User Interface when starting The Terminal User Interface manages several text windows on the terminal showing source assembly registers and gdb command outputs refer to Chapter 24 gdb Text User Interface Do not use this option if you run gdb from Emacs refer to Chapter 25 Using gdb under gnu Emacs interpreter interp Use the interpreter interp for interfac...

Page 26: ...ice you can release it with the detach command refer to Section 6 7 Debugging an already running process 4 3 Shell commands If you need to execute occasional shell commands during your debugging session there is no need to leave or suspend gdb you can just use the shell command shell command string Invoke a standard shell to execute command string If it exists the environment variable SHELL determ...

Page 27: ...verwrite on off By default gdb will append to the logfile Set overwrite if you want set logging on to overwrite the logfile instead set logging redirect on off By default gdb output will go to both the terminal and the logfile Set redirect if you want output to go only to the log file show logging Show the current values of the logging settings ...

Page 28: ...18 Chapter 4 Getting In and Out of gdb ...

Page 29: ...ds whose unintentional repetition might cause trouble and which you are unlikely to want to repeat The list and x commands when you repeat them with RET construct new arguments rather than repeating exactly as typed This permits easy scanning of source or memory gdb can also use RET in another way to partition lengthy output in a way similar to the common utility more refer to Section 21 4 Screen ...

Page 30: ...f alternatives in the first place you can press M rather than pressing TAB twice M means META You can type this either by holding down a key designated as the META shift on your keyboard if there is one while typing or as ESC followed by Sometimes the string you need while logically a word may contain parentheses or other characters that gdb normally excludes from its notion of a word To permit wo...

Page 31: ...s Specifying and examining files internals Maintenance commands obscure Obscure features running Running the program stack Examining the stack status Status inquiries support Support facilities tracepoints Tracing of program execution without stopping the program user defined User defined commands Type help followed by a class name for a list of commands in that class Type help followed by command...

Page 32: ...many topics of inquiry this manual introduces each of them in the appropriate context The listings under info and under show in the Index point to all the sub commands Refer to Red Hat Enterprise Linux 3 info This command abbreviated i is for describing the state of your program For example you can list the arguments given to your program with info args list the registers currently in use with inf...

Page 33: ...u may need to determine which version of gdb you are running as gdb evolves new commands are introduced and old ones may wither away Also many system vendors ship variant versions of gdb and there are variant versions of gdb in gnu Linux distributions as well The version number is the same as the one announced when you start gdb show copying Display information about permission for copying gdb sho...

Page 34: ...24 Chapter 5 gdb Commands ...

Page 35: ... C compilers are unable to handle the g and O options together Using those compilers you cannot generate optimized executables containing debugging information gcc the gnu C compiler supports g with or without O making it possible to debug optimized code We recommend that you always use g whenever you compile a program You may think your program is correct but there is no sense in pushing your luc...

Page 36: ...ram s working directory The standard input and output Your program normally uses the same device for standard input and standard output as gdb is using You can redirect input and output in the run command line or you can use the tty command to set a different device for your program Refer to Section 6 6 Your program s input and output Warning While input and output redirection work you cannot use ...

Page 37: ... program The value of PATH used by gdb does not change You may specify several directory names separated by whitespace or by a system dependent separator character on Unix on MS DOS and MS Windows If directory is already in the path it is moved to the front so it is searched sooner You can use the string cwd to refer to whatever is the current working directory at the time gdb searches the path If...

Page 38: ...ted from its parent process typically the shell but you can specify a new working directory in gdb with the cd command The gdb working directory also serves as a default for the commands that specify files for gdb to operate on Refer to Section 17 1 Commands to specify files cd directory Set the gdb working directory to directory pwd Print the gdb working directory 6 6 Your program s input and out...

Page 39: ...rrent working directory then if the program is not found by using the source file search path refer to Section 9 4 Specifying source directories You can also use the file command to load the program Refer to Section 17 1 Commands to specify files The first thing gdb does after arranging to debug the specified process is to stop it You can examine and modify an attached process with all the gdb com...

Page 40: ...ese facilities for debugging multi thread programs automatic notification of new threads thread threadno a command to switch among threads info threads a command to inquire about existing threads thread apply threadno all args a command to apply a command to a list of threads thread specific breakpoints Warning These facilities are not yet available on every gdb configuration where the operating s...

Page 41: ...read number a small integer assigned in thread creation order with each thread in your program Whenever gdb detects a new thread in your program it displays both gdb s thread number and the target system s identification for the thread with a message in the form New systag systag is a thread identifier whose form varies depending on the particular system For example on HP UX you see New thread 2 s...

Page 42: ...ting watchpoints for information about watchpoints in programs with mul tiple threads 6 10 Debugging programs with multiple processes On most systems gdb has no special support for debugging programs which create additional pro cesses using the fork function When a program forks gdb will continue to debug the parent process and the child process will run unimpeded If you have set a breakpoint in a...

Page 43: ...r vfork call If you ask to debug a child process and a vfork is followed by an exec gdb executes the new target up to the first breakpoint in the new target If you have a breakpoint set on main in your original program the breakpoint will also be set on the child process s main When a child process is spawned by vfork you cannot debug the child or parent until an exec call completes If you issue a...

Page 44: ...34 Chapter 6 Running Programs Under gdb ...

Page 45: ...rogram for example routines that are arguments in a pthread_create call A watchpoint is a special breakpoint that stops your program when the value of an expression changes You must use a different command to set watchpoints refer to Section 7 1 2 Setting watchpoints but aside from that you can manage a watchpoint like any other breakpoint you enable disable and delete both breakpoints and watchpo...

Page 46: ... a breakpoint at entry to function function found in file filename Specifying a file name as well as a function name is superfluous except when multiple files contain similarly named functions break address Set a breakpoint at address address You can use this to set breakpoints in parts of your program which do not have debugging information or source files break When called without any arguments ...

Page 47: ...7 1 6 Break conditions 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 way However like the tbreak com mand the breakpoint is automatically deleted after the first time your program stops there Also like the hbreak command the breakpoint requires hardware support and some target hardware may...

Page 48: ...ur program There is nothing silly or meaningless about this When the breakpoints are conditional this is even useful refer to Section 7 1 6 Break conditions 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 You can...

Page 49: ...that are up to 4 bytes wide on such systems you cannot set hardware watchpoints for an expression that yields a double precision floating point number which is typically 8 bytes wide As a work around it might be possible to break the large region into a series of smaller ones and watch them with separate watchpoints If you set too many hardware watchpoints gdb might be unable to insert all of them...

Page 50: ...ity changes the expression HP UX Warning In multi thread programs software watchpoints have only limited usefulness If gdb cre ates a software watchpoint it can only watch the value of an expression in a single thread If you are confident that the expression can only change due to the current thread s activity and if you are also con fident that no other thread can become current then you can use ...

Page 51: ...u can see the stack before any unwinding takes place If you set a breakpoint in an exception handler instead it may not be easy to find out where the exception was raised To stop just before an exception handler is called you need some knowledge of the implementation In the case of gnu C exceptions are raised by calling a library function named __raise_exception which has the following ANSI C inte...

Page 52: ...ive as if it had been deleted but remembers the information on the breakpoint so that you can enable it again later You disable and enable breakpoints watchpoints and catchpoints with the enable and disable commands optionally specifying one or more breakpoint numbers as arguments Use info break or info watch to print a list of breakpoints watchpoints and catchpoints if you do not know which numbe...

Page 53: ...r watchpoints you may not need them since a watchpoint is inspecting the value of an expression anyhow but it might be simpler say to just set a watchpoint on a variable name and specify a condition that tests whether the new value 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 p...

Page 54: ...hed specify a count of zero When you use continue to resume execution of your program from a breakpoint you can specify an ignore count directly as an argument to continue rather than using ignore Refer to Section 7 2 Continuing and stepping If a breakpoint has a positive ignore count and a condition the condition is not checked Once the ignore count reaches zero gdb resumes checking the condition...

Page 55: ...eakpoint commands is to compensate for one bug so you can test for another Put a breakpoint just after the erroneous line of code give it a condition to detect the case in which something erroneous has been done and give it commands to assign correct values to any variables that need them End with the continue command so that your program does not stop and start with the silent command so that no ...

Page 56: ...ng in another process When this happens you have three ways to proceed 1 Remove or disable the breakpoints then continue 2 Suspend gdb and copy the file containing your program to a new name Resume gdb and use the exec file command to specify that gdb should run your program under that name Then start your program again 3 Relink your program so that the text segment is nonsharable using the linker...

Page 57: ...typical technique for using stepping is to set a breakpoint refer to Section 7 1 Breakpoints watch points and catchpoints at the beginning of the function or the section of your program where a problem is believed to lie run your program until it stops at that breakpoint and then step through the suspect area examining the variables that are interesting until you see the problem happen step Contin...

Page 58: ...he returned value if any Contrast this with the return command refer to Section 16 4 Returning from a function until u Continue running until a source line past the current line in the current stack frame is reached This command is used to avoid 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 un...

Page 59: ...ned 94 int factorial int value 95 96 if value 1 97 value factorial value 1 98 99 return value 100 advance location Continue running the program up to the given location An argument is required anything of the same form as arguments for the break command Execution will also stop upon exit from the current stack frame This command is similar to until but advance will not skip over recursive function...

Page 60: ...o handle Print a table of all the kinds of signals and how gdb has been told to handle each one You can use this to see the signal numbers of all the defined types of signals info handle is an alias for info signals handle signal keywords Change the way gdb handles signal signal signal can be the number of a signal or its name with or without the SIG at the beginning a list of signal numbers of th...

Page 61: ...writing them but the effect is always to specify some source line Use the qualifier thread threadno with a breakpoint command to specify that you only want gdb to stop the program when a particular thread reaches this breakpoint threadno is one of the numeric thread identifiers assigned by gdb shown in the first column of the info threads display If you do not specify thread threadno when you set ...

Page 62: ...eizing the prompt by preempting the current thread while you are stepping Other threads will only rarely or never get a chance to run when you step They are more likely to run when you next over a function call and they are completely free to run when you use commands like continue until or finish However unless another thread hits a breakpoint during its timeslice they will never steal the gdb pr...

Page 63: ... the function main This is called the initial frame or the outermost frame Each time a function is called a new frame is made Each time a function returns the frame for that function invocation is eliminated If a function is recursive there can be many frames for the same function The frame for the function in which execution is actually occurring is called the innermost frame This is the most rec...

Page 64: ...t only the outermost n frames 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 value 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 function The program counter value is om...

Page 65: ...ress addr This is useful mainly if the chaining of stack frames has been damaged by a bug making it impossible for gdb to assign numbers properly to all frames In addition this can be useful when your program has multiple stacks and switches between them On the SPARC architecture frame needs two addresses to select an arbitrary frame a frame pointer and a stack pointer On the MIPS and Alpha archit...

Page 66: ...mands to print information about the selected stack frame frame f When used without any argument this command does not change which frame is selected but prints a brief description of the currently selected stack frame It can be abbreviated f With an argument this command is used to select a stack frame Refer to Section 8 3 Selecting a frame info frame info f This command prints a verbose descript...

Page 67: ...rgs Print the arguments of the selected frame each on a separate line info locals Print the local variables of the selected frame each on a separate line These are all variables declared either static or automatic accessible at the point of execution of the selected frame info catch Print a list of all the exception handlers that are active in the current stack frame at the current point of execut...

Page 68: ...58 Chapter 8 Examining the Stack ...

Page 69: ...ction list Print more lines If the last lines printed were printed with a list command this prints lines following the last lines printed however if the last line printed was a solitary line printed as part of displaying a stack frame refer to Chapter 8 Examining the Stack this prints lines centered around that line list Print lines just before the lines last printed By default gdb prints ten sour...

Page 70: ...first linespec offset Specifies the line offset lines after the last line printed When used as the second linespec in a list command that has two this specifies the line offset lines down from the first linespec offset Specifies the line offset lines before the last line printed filename number Specifies line number in the source file filename function Specifies the line that begins the body of th...

Page 71: ...begins the body of the function function in the file filename You only need the file name with a function name to avoid ambiguity when there are identically named functions in different source files edit address Specifies the line containing the program address address address may be any expression 9 2 1 Choosing your editor You can customize gdb to use any editor you want 1 By default it is bin e...

Page 72: ...db looks in the current directory as a last resort Whenever you reset or rearrange the source path gdb clears out any information it has cached about where source files are found and where each line is in the file When you start gdb its source path includes only cdir and cwd in that order To add other directories use the directory command directory dirname dir dirname Add directory dirname to the ...

Page 73: ...4 After info line the default address for the x command is changed to the starting address of the line so that x i is sufficient to begin examining the machine code refer to Section 10 5 Examining memory Also this address is saved as the value of the convenience variable _ refer to Section 10 9 Convenience variables disassemble This specialized command dumps a range of memory as machine instructio...

Page 74: ...ruction set to use when disassembling the program via the disassemble or x i commands Currently this command is only defined for the Intel x86 family You can set instruction set to either intel or att The default is att the AT T flavor used by default by Unix assemblers for x86 based targets ...

Page 75: ...l Table 10 1 Expressions print and many other gdb commands accept an expression and compute its value Any kind of constant variable or operator defined by the programming language you are using is valid in an expression in gdb This includes conditional expressions function calls casts and string constants It also includes preprocessor macros if you compiled your program to include this information...

Page 76: ...execution in that frame This means that in the function foo a int a bar a int b test bar b you can examine and use the variable a whenever your program is executing within the function foo but you can only use or examine the variable b while your program is executing inside the block where b is declared There is an exception you can refer to a variable or function whose scope is a single source fi...

Page 77: ...s offered by the debug info format used by the compiler gdb might not be able to display values for such local variables If that happens gdb will print a message like this No symbol foo in current context To solve such problems either recompile without optimizations or use a different debug info format if the compiler supports several such formats For example gcc the gnu C C compiler usually suppo...

Page 78: ...k around in this situation is to use a convenience variable refer to Section 10 9 Convenience variables as a counter in an expression that prints the first interesting value and then repeat that expression via RET For instance suppose you have an array dtab of pointers to structures and you are interested in the values of a field fv in each structure Here is an example of what you might type set i...

Page 79: ...equired before the slash this is because command names in gdb cannot contain a slash To reprint the last value in the value history with a different format you can use the print command with just a format and no expression For example p x reprints the last value in hex 10 5 Examining memory You can use the command x for examine to examine memory in any of several formats indepen dently of your pro...

Page 80: ...e to the starting address of a line and print if you use it to display a value from memory For example x 3uh 0x54320 is a request to display three halfwords h of memory formatted as unsigned decimal integers u starting at address 0x54320 x 4xw sp prints the four words w of memory above the stack pointer here sp refer to Section 10 10 Registers in hexadecimal x Since the letters indicating unit siz...

Page 81: ...As with displays you request manually using x or print you can specify the output format you prefer in fact display decides whether to use print or x depending on how elaborate your format specification is it uses x if you specify a unit size or one of the two formats i and s that are only supported by x otherwise it uses print display expr Add the expression expr to the list of expressions to dis...

Page 82: ...xample if you give the command display last_char while inside a function with an argument last_char gdb displays this argument while your program continues to stop inside that function When it stops elsewhere where there is no variable last_char the display is disabled automatically The next time your program stops where last_char is meaningful you can enable the display expression once again 10 7...

Page 83: ...c form of an address Another situation where it is helpful to show symbol filenames and line numbers is when disassem bling code gdb shows you the line number and source file that corresponds to each instruction Also you may wish to see the symbolic form only if the address being printed is reasonably close to the closest earlier symbol set print max symbolic offset max offset Tell gdb to only dis...

Page 84: ...isplay of strings When gdb starts this limit is set to 200 Setting number of elements to zero means that the printing is unlimited show print elements Display the number of elements of a large array that gdb will print If the number is 0 then the printing is unlimited set print null stop Cause gdb to stop printing the characters of an array when the first null is encountered This is useful when la...

Page 85: ...default setting set print union off Tell gdb not to print unions which are contained in structures show print union Ask gdb whether or not it will print unions which are contained in structures For example given the declarations typedef enum Tree Bug Species typedef enum Big_tree Acorn Seedling Tree_forms typedef enum Caterpillar Cocoon Butterfly Bug_forms struct thing Species it union Tree_forms ...

Page 86: ...is is the default hp Decode based on the HP ANSI C aCC encoding algorithm lucid Decode based on the Lucid C compiler lcc encoding algorithm arm Decode using the algorithm in the C Annotated Reference Manual Warning this set ting alone is not sufficient to allow debugging cfront generated executables gdb would require further enhancement to permit that If you omit style you will see a list of possi...

Page 87: ...mbol table changes the value history is discarded since the values may contain pointers back to the types defined in the symbol table The values printed are given history numbers by which you can refer to them These are successive integers starting with one print shows you the history number assigned to a value by printing num before the value here num is the history number To refer to any previou...

Page 88: ...f your program and setting a convenience variable has no direct effect on further execution of your program That is why you can use them freely Convenience variables are prefixed with Any name preceded by can be used for a convenience variable unless it is one of the predefined machine specific register names refer to Section 10 10 Registers Value history references in contrast are numbers precede...

Page 89: ...ress examined Its type is chosen to match the format in which the data was printed _exitcode The variable _exitcode is automatically set to the exit code when the program being debugged terminates On HP UX systems if you refer to a function or variable name that begins with a dollar sign gdb searches for a user or system name first before it searches for a convenience variable 10 10 Registers You ...

Page 90: ...lthough you can print it as a floating point value with print f regname Some registers have distinct raw and virtual data formats This means that the data format in which the register contents are saved 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 saved in extended raw format but all C progr...

Page 91: ... to determine whether to allow certain types of memory accesses whether to use specific width accesses and whether to cache target memory Defined memory regions can be individually enabled and disabled When a memory region is disabled gdb uses the default attributes when accessing memory in that region Similarly if no memory regions have been defined gdb uses the default attributes when accessing ...

Page 92: ...ry Access Mode The access mode attributes set whether gdb may make read or write accesses to a memory region While these attributes prevent gdb from performing invalid memory accesses they do nothing to prevent the target system I O DMA etc from accessing memory ro Memory is read only wo Memory is write only rw Memory is read write This is the default 10 13 1 2 Memory Access Size The acccess size ...

Page 93: ...rget memory and a file The dump and append commands write data to a file and the restore command reads data from a file back into the inferior s memory Files may be in binary Motorola S record Intel hex or Tektronix Hex format however gdb can only append to binary files dump format memory filename start_addr end_addr dump format value filename expr Dump the contents of memory from start_addr to en...

Page 94: ...which uses the ISO Latin 1 character set but you are using gdb s remote protocol Remote Debugging to debug a program running on an IBM mainframe which uses the ebcdic character set then the host character set is Latin 1 and the target character set is ebcdic If you give gdb the command set target charset EBCDIC US then gdb translates between ebcdic and Latin 1 as you print character or string valu...

Page 95: ...e as its host character set Note that these are all single byte character sets More work inside GDB is needed to support multi byte or variable width character encodings like the UTF 8 and UCS 2 encodings of Unicode Here is an example of gdb s character set support in action Assume that the following source code has been placed in the file charset test c include stdio h char ascii_hello 72 101 108...

Page 96: ...rly Since our current target character set is also ascii the contents of ascii_hello print legibly gdb print ascii_hello 1 0x401698 Hello world n gdb print ascii_hello 0 2 72 H gdb gdb uses the target character set for character and string literals you use in expressions gdb print 3 43 gdb The ascii character set uses the number 43 to encode the character gdb relies on the user to tell it which ch...

Page 97: ...t target charset IBM1047 gdb show charset The current host character set is ASCII The current target character set is IBM1047 gdb print ascii_hello 6 0x401698 110 145 054 040 167 162 144 041 012 gdb print ascii_hello 0 7 72 110 gdb print ibm1047_hello 8 0x4016a8 Hello world n gdb print ibm1047_hello 0 9 200 H gdb As above gdb uses the target character set for character and string literals you use ...

Page 98: ...88 Chapter 10 Examining Data ...

Page 99: ...o expand expression macro exp expression Show the results of expanding all preprocessor macro invocations in expression Since gdb simply expands macros but does not parse the result expression need not be a valid expres sion it can be any string of tokens macro expand once expression macro exp1 expression This command is not yet implemented Show the results of expanding those preprocessor macro in...

Page 100: ...define M 42 define ADD x M x main define N 28 printf Hello world n undef N printf We re so creative n define N 1729 printf Goodbye world n cat sample h define Q Now we compile the program using the gnu C compiler gcc We pass the gdwarf 2 and g3 flags to ensure the compiler includes information about preprocessor macros in the debugging information gcc gdwarf 2 g3 sample c o sample Now we start gdb...

Page 101: ... Once the program is running GDB uses the macro definitions in force at the source line of the current stack frame gdb break main Breakpoint 1 at 0x8048370 file sample c line 10 gdb run Starting program home jimb gdb macros play sample Breakpoint 1 main at sample c 10 10 printf Hello world n gdb At line 10 the definition of the macro N at line 9 is in force gdb info macro N Defined at home jimb gd...

Page 102: ...1 C Preprocessor Macros We re so creative 14 printf Goodbye world n gdb info macro N Defined at home jimb gdb macros play sample c 13 define N 1729 gdb macro expand N Q M expands to 1729 42 gdb print N Q M 2 0 gdb ...

Page 103: ...ints as of this writing This chapter describes the tracepoint commands and features 12 1 Commands to Set Tracepoints Before running such a trace experiment an arbitrary number of tracepoints can be set Like a break point refer to Section 7 1 1 Setting breakpoints a tracepoint has a number assigned to it by gdb Like with breakpoints tracepoint numbers are successive integers starting from one Many ...

Page 104: ...nt but it is not forgotten You can re enable a disabled tracepoint using the enable tracepoint command enable tracepoint num Enable tracepoint num or all tracepoints The enabled tracepoints will become effective the next time a trace experiment is run 12 1 3 Tracepoint Passcounts passcount n num Set the passcount of a tracepoint The passcount is a way to automatically stop a trace experiment If a ...

Page 105: ...ect data collect some data gdb while stepping 5 single step 5 times collect data gdb end signals the end of actions In the following example the action list begins with collect commands indicating the things to be collected when the tracepoint is hit Then in order to single step and collect additional data following the tracepoint a while stepping command is used followed by the list of things to ...

Page 106: ...lobal end You may abbreviate while stepping as ws or stepping 12 1 5 Listing Tracepoints info tracepoints num Display information about the tracepoint num If you don t specify a tracepoint number displays information about all the tracepoints defined so far For each tracepoint the following informa tion is shown its number whether it is enabled or disabled its address its passcount as given by the...

Page 107: ...e tracepoint experiment ends you use gdb commands for examining the trace data The basic idea is that each tracepoint collects a trace snapshot every time it is hit and another snapshot every time it single steps All these snapshots are consecutively numbered from zero and go into a buffer and you can examine them later The way you examine them is to focus on a specific trace snapshot When the rem...

Page 108: ...at source file Search proceeds forward from the last examined trace snapshot If no argument n is given it means find the next line other than the one currently being examined thus saying tfind line repeatedly can appear to have the same effect as stepping from line to line in a live debugging session The default arguments for the tfind commands are specifically designed to make it easy to scan thr...

Page 109: ...Frame 10 PC 00203F6C SP 0030BE3C FP 0030BF14 Or if we want to examine the variable X at each source line in the buffer gdb tfind start gdb while trace_frame 1 printf Frame d X d n trace_frame X tfind line end Frame 0 X 1 Frame 7 X 2 Frame 13 X 255 12 2 2 tdump This command takes no arguments It prints all the data collected at the current trace snapshot gdb trace 444 gdb actions Enter actions for ...

Page 110: ...2 2 3 save tracepoints filename This command saves all current tracepoint definitions together with their actions and passcounts into a file filename suitable for use in a later debugging session To read the saved tracepoint definitions use the source command refer to Section 22 3 Command files 12 3 Convenience Variables for Tracepoints int trace_frame The current trace snapshot a k a frame number...

Page 111: ...s not suitable for use in printf use output instead Here s a simple example of using these convenience variables for stepping through all the trace snap shots and printing some of their data gdb tfind start gdb while trace_frame 1 output trace_file printf line d tracepoint d n trace_line tracepoint tfind end ...

Page 112: ...102 Chapter 12 Tracepoints ...

Page 113: ...and place their machine code in the larger memory Place your main program in instruction memory but leave at least enough space there to hold the largest overlay as well Now to call a function located in an overlay you must first copy that overlay s machine code from the large memory into the space set aside for it in the instruction memory and then jump to its entry point there Data Instruction L...

Page 114: ... files onto your system must be able to load their contents into the larger address space as well as the instruction and data spaces The overlay system described above is rather simple and could be improved in many ways If your system has suitable bank switch registers or memory management hardware you could use those facilities to make an overlay s load area contents simply appear at their mapped...

Page 115: ...debugging In this mode gdb consults a data structure the overlay manager maintains in the inferior to see which overlays are mapped For details refer to Section 13 3 Automatic Overlay Debugging overlay load target overlay load Re read the overlay table from the inferior Normally gdb re reads the table gdb automatically each time the inferior stops so this command should only be necessary if you ha...

Page 116: ...are mapped and which are not given some simple co operation from the overlay manager in the inferior If you enable automatic overlay debugging with the overlay auto command refer to Section 13 2 Overlay Commands gdb looks in the inferior s memory for certain variables describing the current state of the overlays Here are the variables your overlay manager must define to support gdb s automatic ove...

Page 117: ...chitecture and target memory layout this manual cannot provide portable sample code demonstrating gdb s overlay support However the gdb source distribution does contain an overlaid program with linker scripts for a few systems as part of its test suite The program consists of the following files from gdb testsuite gdb base overlays c The main program file ovlymgr c A simple overlay manager used by...

Page 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...

Page 119: ... pressions you type are interpreted how values are printed etc In addition to the working language every source file that gdb knows about has its own working language For some object file formats the compiler might indicate which language a particular source file is in However most of the time gdb infers the language from the name of the file The language of a source file controls whether C names ...

Page 120: ...e current source file were written in C and gdb was parsing Modula 2 a command such as print a b c might not have the effect you intended In C this means to add b and c and place the result in a The result printed would be the value of a In Modula 2 this means to compare a to the result of b c yielding a BOOLEAN value 14 1 3 Having gdb infer the source language To have gdb set the working language...

Page 121: ...ange checking Warning In this release the gdb commands for type and range checking are included but they do not yet have any effect This section documents the intended facilities Some languages are designed to guard you against making seemingly common errors through a series of compile and run time checks These include checking the type of arguments to functions and operators and making sure mathe...

Page 122: ...ng on or off based on the current working language Refer to Section 14 4 Sup ported languages for the default settings for each language set check type on set check type off Set type checking on or off overriding the default setting for the current working language Issue a warning if the setting does not match the language default If any type mismatches occur in evaluating an expression while type...

Page 123: ...ll be impossible for other reasons such as accessing memory that the process does not own a typical example from many Unix systems show range Show the current setting of the range checker and whether or not it is being set automatically by gdb 14 4 Supported languages gdb supports C C Objective C Fortran Java assembly and Modula 2 Some gdb features may be used in expressions regardless of the lang...

Page 124: ...at form Pointer types include all types defined as type Scalar types include all of the above The following operators are supported They are listed here in order of increasing precedence The comma or sequencing operator Expressions in a comma separated list are evaluated from left to right with the result of the entire expression being the last expression evaluated Assignment The value of an assig...

Page 125: ...ing before a variable the operation is performed before the variable is used in an expression when appearing after it the variable s value is used before the operation takes place Pointer dereferencing Defined on pointer types Same precedence as Address operator Defined on variables Same precedence as For debugging C gdb implements a use of beyond what is allowed in the C language itself you can u...

Page 126: ...xponents A floating point constant may also end with a letter f or F specifying that the constant should be treated as being of the float as opposed to the default double type or with a letter l or L which specifies a long double constant Enumerated constants consist of enumerated identifiers or their integral equivalents Character constants are a single character surrounded by single quotes or a ...

Page 127: ...ns pointer conversions conversions of class objects to base classes and standard conver sions such as those of functions or arrays to pointers it requires an exact match on the number of function arguments Overload resolution is always performed unless you have specified set overload resolution off Refer to Section 14 4 1 7 gdb features for C You must specify set overload resolution off in order t...

Page 128: ... 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 14 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 printed Otherwise it appears as The operator aids in the debugging of dyna...

Page 129: ...the standard C conversion rules refer to Section 14 4 1 3 C expressions for details If it cannot find a match it emits a message set overload resolution off Disable overload resolution for C expression evaluation For overloaded functions that are not class member functions gdb chooses the first function of the specified name that it finds in the symbol table whether or not its arguments are of the...

Page 130: ...d enter list NSText initialize In the current version of GDB the plus or minus sign is required In future versions of GDB the plus or minus sign will be optional but you can use it to narrow the search It is also possible to specify just a method name break create You must specify the complete method name including any colons If your program s source files contain more than one create method you l...

Page 131: ...roups of types For the purposes of Modula 2 the following definitions hold Integral types consist of INTEGER CARDINAL and their subranges Character types consist of CHAR and its subranges Floating point types consist of REAL Pointer types consist of anything declared as POINTER TO type Scalar types consist of all of the above Set types consist of SET and BITSET types Boolean types consist of BOOLE...

Page 132: ...set types Same precedence as DIV MOD Integer division and remainder Defined on integral types Same precedence as Negative Defined on INTEGER and REAL data Pointer dereferencing Defined on pointer types NOT Boolean negation Defined on boolean types Same precedence as RECORD field selector Defined on RECORD data Same precedence as Array indexing Defined on ARRAY data Same precedence as Procedure arg...

Page 133: ...s the type of m n represents a variable or constant of integral or floating point type r represents a variable or constant of floating point type t represents a type v represents a variable x represents a variable or constant of one of many types See the explanation of the function for details All Modula 2 built in procedures also return a result described below ABS n Returns the absolute value of...

Page 134: ... Returns the maximum value of the type t MIN t Returns the minimum value of the type t ODD i Returns boolean TRUE if i is an odd number ORD x Returns the ordinal value of its argument For example the ordinal value of a character is its ascii value on machines supporting the ascii character set x must be of an ordered type which include integral character and enumerated types SIZE x Returns the siz...

Page 135: ...s TRUE and FALSE Pointer constants consist of integral values only Set constants are not yet supported 14 4 3 4 Modula 2 defaults If type and range checking are set automatically by gdb they both default to on whenever the working language changes to Modula 2 This happens regardless of whether you or gdb selected the working language If you allow gdb to set the language automatically then entering...

Page 136: ... makes gdb search the scope specified by scope for the identifier id If it is not found in the specified scope then gdb searches all scopes enclosing the one specified by scope Using the operator makes gdb search the current scope for the identifier specified by id that was imported from the definition module specified by module With this operator it is an error if the identifier id was not import...

Page 137: ...ot represent a real programming language but provides a set of capabilities close to what the C or assembly languages provide This should allow most simple operations to be performed while debugging an application that uses a language currently not supported by gdb If the language is set to auto gdb will automatically select this language if the current frame corre sponds to an unsupported languag...

Page 138: ...128 Chapter 14 Using gdb with Different Languages ...

Page 139: ...dress symbol Describe where the data for symbol is stored For a register variable this says which register it is kept in For a non register local variable this prints the stack frame offset at which the variable is always stored Note the contrast with print symbol which does not work at all for a register variable and for a stack local variable prints the exact address of the current instantiation...

Page 140: ... not print a detailed description second it lists all source files where a type is defined info scope addr List all the variables local to a particular scope This command accepts a location a function name a source line or an address preceded by a and prints all the variables local to the scope defined by that location For example gdb info scope command_line_handler Scope for command_line_handler ...

Page 141: ...eg operator they may be quoted with a backslash info variables Print the names and data types of all variables that are declared outside of functions that is excluding local variables info variables regexp Print the names and data types of all variables except for local variables whose names contain a match for regular expression regexp info classes info classes regexp Display all Objective C clas...

Page 142: ...ymbols filename Write a dump of debugging symbol data into the file filename These commands are used to debug the gdb symbol reading code Only symbols with debugging data are included If you use maint print symbols gdb includes all the symbols for which it has already collected full details that is filename reflects symbols for only those files whose symbols gdb has read You can use the command in...

Page 143: ...le and we see that gdb has not read in any symtabs yet at all If we set a breakpoint on a function that will cause gdb to read the symtab for the compilation unit containing that function gdb break dwarf2_psymtab_to_symtab Breakpoint 1 at 0x814e5da file home gnu src gdb dwarf2read c line 1574 gdb maint info symtabs objfile home gnu build gdb gdb struct objfile 0x82e69d0 symtab home gnu src gdb dwa...

Page 144: ...134 Chapter 15 Examining the Symbol Table ...

Page 145: ...ommand set is really the same as print except that the expression s value is not printed and is not put in the value history refer to Section 10 8 Value history The expression is evaluated only for its effects If the beginning of the argument string of the set command appears identical to a set subcommand use the set variable command instead of just set This command is identical to set except for ...

Page 146: ... stores the value 4 into that memory location 16 2 Continuing at a different address Ordinarily when you continue your program you do so at the place where it stopped with the continue command You can instead continue at an address of your own choosing with the fol lowing commands jump linespec Resume execution at line linespec Execution stops again immediately if there is a break point there Refe...

Page 147: ...ommand signal 0 causes it to resume without a signal signal does not repeat when you press RET a second time after executing the command Invoking the signal command is not the same as invoking the kill utility from the shell Sending a signal with kill causes gdb to decide what to do with the signal depending on the signal handling tables refer to Section 7 3 Signals The signal command passes the s...

Page 148: ...machine code but it also prevents you from intentionally patch ing your program s binary If you d like to be able to patch the binary you can specify that explicitly with the set write com mand For example you might want to turn on internal debugging flags or even to make emergency repairs set write on set write off If you specify set write on gdb opens executable and core files for both reading a...

Page 149: ...th memory mapped files an auxiliary file named filename syms may hold symbol table information for filename If so gdb maps in the symbol table from filename syms starting up more quickly See the descriptions of the file options mapped and readnow available on the command line and with the commands file symbol file or add symbol file described below for more information file file with no argument m...

Page 150: ... symbol table information if you want to be sure gdb has the entire symbol table available If memory mapped files are available on your system through the mmap system call you can use another option mapped to cause gdb to write the symbols for your program into a reusable file Future gdb debugging sessions map in symbol information from this auxiliary symbol file if the program has not changed rat...

Page 151: ... loaded and provide these to the add symbol file command Some embedded operating systems like Sun Chorus and VxWorks can load relocatable files into an already running program such systems typically make the requirements above easy to meet However it s important to recognize that many native systems use complex link procedures linkonce section factoring and C constructor table assembly for example...

Page 152: ...files including shared libraries sections Display info only for named sections section flags Display info only for sections for which section flags are true The section flags that gdb currently knows about are ALLOC Section will have space allocated in the process when loaded Set for all sections except those containing debug information LOAD Section will be loaded from the file into the child pro...

Page 153: ...000 shared libraries gdb automatically loads symbol definitions from shared libraries when you use the run command or when you examine a core file Before you issue the run command gdb does not understand references to a function in a shared library however unless you are debugging a core file On HP UX if the program loads a library explicitly gdb automatically loads the symbols at the time of the ...

Page 154: ...olib limit Display the current autoloading size threshold in megabytes Shared libraries are also supported in many cross or remote debugging configurations A copy of the target s libraries need to be present on the host system they need to be the same as the target libraries although the copies on the target can be stripped as long as the copies on the host are not You need to tell gdb where the t...

Page 155: ...the link that is the file globaldebugdir execdir debugfile where globaldebugdir is the global debug file directory and execdir has been turned into a relative path gdb checks under each of these names for a debugging information file whose checksum matches that given in the link and reads the debugging information from the first one it finds So for example if you ask gdb to debug usr bin ls which ...

Page 156: ...6b 0x35b5a8fa 0x42b2986c 0xdbbbc9d6 0xacbcf940 0x32d86ce3 0x45df5c75 0xdcd60dcf 0xabd13d59 0x26d930ac 0x51de003a 0xc8d75180 0xbfd06116 0x21b4f4b5 0x56b3c423 0xcfba9599 0xb8bda50f 0x2802b89e 0x5f058808 0xc60cd9b2 0xb10be924 0x2f6f7c87 0x58684c11 0xc1611dab 0xb6662d3d 0x76dc4190 0x01db7106 0x98d220bc 0xefd5102a 0x71b18589 0x06b6b51f 0x9fbfe4a5 0xe8b8d433 0x7807c9a2 0x0f00f934 0x9609a88e 0xe10e9818 0...

Page 157: ...w many times the problem occurs or you can ask gdb to print more messages to see how many times the problems occur with the set complaints command refer to Section 21 7 Optional warnings and messages The messages currently printed and their meanings include inner block not inside outer block in symbol The symbol information shows where symbol scopes begin and end such as at the start of a function...

Page 158: ...s the error by ignoring this symbol information This usually allows you to debug your program though certain symbols are not accessible If you encounter such a problem and feel like debugging it you can debug gdb with itself breakpoint on complain then go up to the function read_dbx_symtab and examine bufp to see the symbol stub type has NULL name gdb could not find the full definition for a struc...

Page 159: ... only a program s read write memory variables and so on plus machine status while executable files contain only the program text and initialized data When you type run your executable file becomes an active process target as well When a process target is active all gdb commands requesting memory addresses refer to that target addresses in an active core file or executable file target are obscured ...

Page 160: ... the same as core file filename target remote dev Remote serial target in GDB specific protocol The argument dev specifies what serial device to use for the connection e g dev ttya Refer to Section 18 4 Remote debugging target remote supports the load command This is only useful if you have some other way of get ting the stub to the target system and you can put it somewhere in memory where it won...

Page 161: ...e However you may still find it useful to adjust gdb s idea of processor endian ness manually set endian big Instruct gdb to assume the target is big endian set 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 mer...

Page 162: ...command to set the operating system This tells gdb which kernel object display module to initialize gdb set os cisco If set os succeeds gdb will display some information about the operating system and will create a new info command which can be used to query the target The info command is named after the operating system gdb info cisco List of Cisco Kernel Objects Object Description any Any and al...

Page 163: ...ple to connect to port 2828 on a terminal server named manyfarms target remote manyfarms 2828 If your remote target is actually running on the same machine as your debugger session e g a simu lator of your target running on the same host you can omit the hostname For example to connect to port 1234 on your local machine target remote 1234 Note that the colon is still required here To use a UDP con...

Page 164: ...he same operating system facilities that gdb itself does In fact a system that can run gdbserver to connect to a remote gdb could also run gdb locally gdbserver is sometimes useful nevertheless because it is a much smaller program than gdb itself It is also easier to port than all of gdb so you may be able to get started more quickly on a new system by using gdbserver Finally if you develop code f...

Page 165: ...hich usually looks something like Connection refused You don t need to use the load command in gdb when using gdbserver since the program is already on the target 19 3 Using the gdbserve nlmprogram gdbserve nlm is a control program for NetWare systems which allows you to connect your program with a remote gdb via target remote gdb and gdbserve nlm communicate via a serial line using the standard g...

Page 166: ...dware supplier or you may have to write your own 2 A C subroutine library to support your program s subroutine calls notably managing input and output 3 A way of getting your program to the other machine for example a download program These are often supplied by the hardware manufacturer but you may have to write your own from hardware documentation The next step is to arrange for your program to ...

Page 167: ...f your program then continues to execute retrieving and transmitting any information gdb needs until you execute a gdb command that makes your program resume at that point handle_exception returns control to your own code on the target machine breakpoint Use this auxiliary subroutine to make your program contain a breakpoint Depending on the particular situation this may be the only way for gdb to...

Page 168: ...ch should be changed its meaning is architecture dependent for example different numbers might represent divide by zero misaligned access etc When this exception occurs control should be transferred directly to exception_address and the processor state stack registers and so on should be just as it is when a processor exception occurs So if you want to use a jump instruction to reach exception_add...

Page 169: ...alling set_debug_traps you set it to point to a function in your program that function is called when gdb continues after stopping on a trap for example bus error The function indicated by exceptionHook is called with one parameter an int which is the exception number 4 Compile and link together your program the gdb debugging stub for your target architecture and the supporting subroutines 5 Make ...

Page 170: ...160 Chapter 19 Debugging remote programs ...

Page 171: ...f a running process using file system subroutines If gdb is configured for an operating system with this facility the command info proc is available to report on several kinds of information about the process running your program info proc works only on SVR4 systems that include the procfs code This includes OSF 1 Digital Unix Solaris Irix and Unixware but not HP UX or gnu Linux for example info p...

Page 172: ...s outside the data segment s limit that is garbled info dos pde info dos pte These two commands display entries from respectively the Page Directory and the Page Tables Page Directories and Page Tables are data structures which control how virtual memory addresses are mapped into physical addresses A Page Table includes an entry for every page of memory that is mapped into the program s address sp...

Page 173: ...res for Debugging MS Windows PE executables gdb supports native debugging of MS Windows programs including DLLs with and without symbolic debugging information There are various additional Cygwin specific commands described in this subsection The subsubsection refer to Section 20 1 4 1 Support for DLLs without debugging symbols describes working with DLLs that have no debugging symbols info w32 Th...

Page 174: ...information contained in the DLL s export table This subsubsection describes working with such symbols known internally to gdb as minimal symbols Note that before the debugged program has started execution no DLLs will have been loaded The easiest way around this problem is simply to start the program either by setting a breakpoint or letting the program run once to completion It is also possible ...

Page 175: ...cygwin1 _dll_crt0 0 0x61004240 cygwin1 dll_crt0 per_process etc 20 1 4 3 Working with minimal symbols Symbols extracted from a DLL s export table do not contain very much type information All that gdb can do is guess whether a symbol refers to a function or variable depending on the linker section that contains the symbol Also note that the actual contents of the memory contained in a DLL are not ...

Page 176: ...s real time operating systems 20 2 1 Using gdb with VxWorks target vxworks machinename A VxWorks system attached via TCP IP The argument machinename is the target system s machine name or IP address On VxWorks load links filename dynamically on the current target system as well as adding its symbols in gdb gdb enables developers to spawn and debug tasks running on networked VxWorks targets from a ...

Page 177: ... last booted gdb locates these files by searching the directories listed in the command search path refer to Section 6 4 Your program s environment if it fails to find an object file it displays a message such as prog o No such file or directory When this happens add the appropriate directory to the search path with the gdb command path and execute the target command again 20 2 1 2 VxWorks downloa...

Page 178: ...o preserve the integrity of debugger s data structures that reference the target system s symbol table 20 2 1 3 Running tasks You can also attach to an existing task using the attach command as follows vxgdb attach task where task is the VxWorks hexadecimal task ID The task can be running or suspended when you attach to it Running tasks are suspended at the time of attachment 20 3 Embedded Process...

Page 179: ...efault port is the first available port on your host This is only necessary on Unix hosts where it is typically something like dev ttya gdb has another special command to set the communications speed speed bps This command also is only used from Unix hosts on DOS hosts set the line speed as usual from outside gdb with the DOS mode command for instance mode com2 9600 n 8 1 p for a 9600bps connectio...

Page 180: ...ils gdb 2003 07 22 cvs Copyright 1992 Free Software Foundation Inc gdb target hms Connected to remote H8 300 HMS system gdb load t x text 0x8000 0xabde data 0xabde 0xad30 stack 0xf000 0xf014 At this point you re ready to run or debug your program From here on you can use all the usual gdb commands The break command sets breakpoints the run command starts your program print or x display data the co...

Page 181: ...set machine h8300 set machine h8300h Condition gdb for one of the two variants of the H8 300 architecture with set machine You can use show machine to check which variant is currently in effect 20 3 3 H8 500 set memory mod show memory Specify which H8 500 memory model mod you are using with set memory check which memory model is in effect with show memory The accepted values for mod are small big ...

Page 182: ...command target mips port where port is the name of the serial port connected to the board If the program has not already been downloaded to the board you may use the load command to download it You can then use all the usual gdb commands For example this sequence connects to the target board through a serial port and loads and runs a program called prog through the debugger host gdb prog gdb is fr...

Page 183: ... versions the only choices were double precision or no floating point so set mipsfpu on will select double precision and set mipsfpu off will select no floating point As usual you can inquire about the mipsfpu variable with show mipsfpu set remotedebug n show remotedebug You can see some debugging information about communications with the board by setting the remotedebug variable If you set it to ...

Page 184: ...spr groupno registerno info or1k spr registerno Shows information about specified spr register spr group register value spr register value spr groupno registerno value spr registerno value Writes value to specified spr register Some implementations of OpenRISC 1000 Architecture also have hardware trace It is very similar to gdb trace except it does not interfere with normal program execution and i...

Page 185: ... qualifier conditional Set acquisition qualifier for HW trace htrace stop conditional Set HW trace stopping criteria htrace record data Selects the data to be recorded when qualifier is met and HW trace was triggered htrace enable htrace disable Enables disables the HW trace htrace rewind filename Clears currently recorded trace data If filename is specified new trace file is made and any newly co...

Page 186: ...n a Winbond HPPA board 20 3 10 Hitachi SH target hms dev A Hitachi SH board attached via serial line to your host Use special commands device and speed to control the serial line and the communications speed used target e7000 dev E7000 emulator for Hitachi SH target sh3 dev target sh3e dev Hitachi SH 3 and SH 3E target systems 20 3 11 Tsqware Sparclet gdb enables developers to debug tasks running ...

Page 187: ...db comes up showing the prompt gdbslet 20 3 11 1 Setting file to debug The gdb command file lets you choose with program to debug gdbslet file prog gdb then attempts to read the symbol table of prog gdb locates the file by searching the directories listed in the command search path If the file was compiled with debug information option g source files will be searched as well gdb locates the source...

Page 188: ...10170 in gdb type gdbslet load prog 0x12010000 Loading section text size 0xdb0 vma 0x12010000 If the code is loaded at a different address then what the program was linked to you may need to use the section and add symbol file commands to tell gdb where to map the symbol table 20 3 11 4 Running and debugging You can now begin debugging the task using gdb s execution control commands b step run etc...

Page 189: ...available com mands connect Connect the controlling terminal to the STDBUG command monitor When you are done inter acting with STDBUG typing either of two character sequences gets you back to the gdb com mand prompt RET Return followed by tilde and period or RET C d Return followed by tilde and control D 20 3 14 Zilog Z8000 When configured for debugging Zilog Z8000 targets gdb includes a Z8000 sim...

Page 190: ...ommand The argument should be an address which you probably want to precede with 0x to specify in hexadecimal show rstack_high_address Display the current limit of the register stack on AMD 29000 family processors 20 4 2 Alpha See the following section 20 4 3 MIPS Alpha and MIPS based computers use an unusual stack frame which sometimes requires gdb to search backward in the object code to find th...

Page 191: ... to use newprompt as its prompt string henceforth show prompt Prints a line of the form Gdb s prompt is your prompt 21 2 Command editing gdb reads its input commands via the readline interface This gnu library provides consistent behavior for programs which provide a command line interface to the user Advantages are gnu Emacs style or vi style inline editing of commands csh like history substituti...

Page 192: ...t set History expansion assigns special meaning to the character Since is also the logical not operator in C history expansion is off by default If you decide to enable history expansion with the set history expansion on command you may sometimes need to follow when it is used as logical not in an expression with a space or a tab to prevent it from being expanded The readline history facilities do...

Page 193: ...cpl show width These set commands specify a screen height of lpp lines and a screen width of cpl characters The associated show commands display the current settings If you specify a height of zero lines gdb does not pause during output no matter how long the output is This is useful if output is to a file or to an editor buffer Likewise you can specify set width 0 to prevent gdb from wrapping its...

Page 194: ...i With no argument show the list of registered available OS ABI s set osabi abi Set the current OS ABI to abi Generally the way that an argument of type float is passed to a function depends on whether the function is prototyped For a prototyped that is ANSI ISO style function float arguments are passed unchanged according to the architecture s convention for float For unprototyped that is K R sty...

Page 195: ... to Section 17 1 Commands to specify files set verbose on Enables gdb output of certain informational messages set verbose off Disables gdb output of certain informational messages show verbose Displays whether set verbose is on or off By default if gdb encounters bugs in the symbol table of an object file it is silent but if you are debugging a compiler you may find this information useful refer ...

Page 196: ...off display of gdb event debugging info The default is off show debug event Displays the current state of displaying gdb event debugging info set debug expression Turns on or off display of gdb expression debugging info The default is off show debug expression Displays the current state of displaying gdb expression debugging info set debug frame Turns on or off display of gdb frame debugging info ...

Page 197: ...ebugging info The default is off show debug serial Displays the current state of displaying gdb serial debugging info set debug target Turns on or off display of gdb target debugging info This info includes what is going on at the target level of GDB as it happens The default is off show debug target Displays the current state of displaying gdb target debugging info set debug varobj Turns on or of...

Page 198: ...188 Chapter 21 Controlling gdb ...

Page 199: ...ressions or even perform inferior functions calls define commandname Define a command named commandname If there is already a command by that name you are asked to confirm that you want to redefine it The definition of the command is made up of other gdb command lines which are given follow ing the define command The end of these commands is marked by a line containing end if Takes a single argume...

Page 200: ... any command stops execution of the user defined command If used interactively commands that would ask for confirmation proceed without asking when used inside a user defined command Many gdb commands that normally print messages to say what they are doing omit the messages when used in a user defined command 22 2 User defined command hooks You may define hooks which are a special kind of user def...

Page 201: ...nd files A command file for gdb is a file of lines that are gdb commands Comments lines starting with may also be included An empty line in a command file does nothing it does not mean to repeat the last command as it would from the terminal When you start gdb it automatically executes commands from its init files normally called gdbinit1 During startup gdb does the following 1 Reads the init file...

Page 202: ...d output and error output goes to standard error Errors in a command file supplied on standard input do not terminate execution of the command file execution continues with the next command gdb O cmds P log 2P 1 The syntax above will vary depending on the shell used This example will execute commands from the file cmds All output and errors would be directed to log 22 4 Commands for controlled out...

Page 203: ...me formats as for print Refer to Section 10 4 Output formats for more information printf string expressions Print the values of the expressions under the control of string The expressions are sep arated by commas and may be either numbers or pointers Their values are printed as specified by string exactly as if your program were to execute the C subroutine printf string expressions For example you...

Page 204: ...194 Chapter 22 Canned Sequences of Commands ...

Page 205: ...erpreter mi The newest gdb mi interface currently mi2 Used primarily by programs wishing to use gdb as a backend for a debugger GUI or an IDE For more information refer to Chapter 26 The gdb mi Interface mi2 The current gdb mi interface mi1 The gdb mi interface included in gdb 5 1 5 2 and 5 3 The interpreter being used by gdb may not be dynamically switched at runtime Although possible this could ...

Page 206: ...196 Chapter 23 Command Interpreters ...

Page 207: ... is the gdb command window with the gdb prompt and the gdb outputs The gdb input is still managed using readline but through the TUI The command window is always visible source The source window shows the source file of the program The current line as well as active breakpoints are displayed in this window assembly The assembly window shows the disassembly output of the program register This windo...

Page 208: ...played target Indicates the current gdb target refer to Chapter 18 Specifying a Debugging Target process Gives information about the current process or thread number When no process is being de bugged this field is set to No process function Gives the current function name for the selected frame The name is demangled if demangling is turned on refer to Section 10 7 Print settings When there is no ...

Page 209: ...1 binding C x 2 Use a TUI layout with at least two windows When the current layout shows already two win dows a next layout with two windows is used When a new layout is chosen one window will always be common to the previous layout and the new one Think of it as the Emacs C x 2 binding C x s Use the TUI SingleKey keymap that binds single key to gdb commands refer to Section 24 3 TUI Single Key Mo...

Page 210: ...lls a particular key binding in the readline keymaps to connect single keys to some gdb commands c continue d down f finish n next q exit the SingleKey mode r run s step u up v info locals w where Other keys temporarily switch to the gdb command prompt The key that was pressed is inserted in the editing buffer so that it is possible to type most gdb commands without interaction with the TUI Single...

Page 211: ... regs Display the register window together with the source or assembly window focus next prev src asm regs split Set the focus to the named window This command allows to change the active window so that scrolling keys can be affected to another window refresh Refresh the screen This is similar to using C L key update Update the source window and the current execution point winheight name count win...

Page 212: ... display the border of the active window The possible values are normal standout reverse half half standout bold and bold standout set tui border mode mode Select the attributes to display the border of other windows The mode can be one of the follow ing normal Use normal attributes to display the border standout Use standout mode reverse Use reverse video mode half Use half bright mode half stand...

Page 213: ...screen to show both your gdb session and the source Explicit gdb list or search commands still produce output as usual but you probably have no reason to use them from Emacs Warning If the directory where your program resides is not your current directory it can be easy to confuse Emacs about the location of the source files in which case the auxiliary display buffer does not appear to show your s...

Page 214: ... In Emacs v19 this command is C c C d C x Read the number where the cursor is positioned and insert it at the end of the gdb I O buffer For example if you wish to disassemble code around an address that was displayed earlier type disassemble then move the cursor to the address display and pick up the argument for disassemble by typing C x You can customize this further by defining elements of the ...

Page 215: ...ffers which are visiting the source files in the usual way You can edit the files with these buffers if you wish but keep in mind that gdb communicates with Emacs in terms of line numbers If you add or delete lines from the text the line numbers that gdb knows cease to correspond properly with the code ...

Page 216: ...206 Chapter 25 Using gdb under gnu Emacs ...

Page 217: ...otation and Terminology This chapter uses the following notation separates two alternatives something indicates that something is optional it may or may not be given group means that group inside the parentheses may repeat zero or more times group means that group inside the parentheses may repeat one or more times string means a literal string 26 3 Acknowledgments In alphabetic order Andrew Cagne...

Page 218: ...by an optional argument parameter Options occur first in the parameter list and can be delimited from normal parameters using this is useful when some parameters begin with a dash Pragmatics We want easy access to the existing CLI syntax for debugging We want it to be easy to spot a mi operation 26 4 2 gdb mi Output Syntax The output from gdb mi consists of zero or more out of band records followe...

Page 219: ...async class result nl result class done running connected error exit async class stopped others where others will be added depending on the needs this is still in development result variable value variable string 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 output console stream output c...

Page 220: ... output is prefixed by console stream output is output that should be displayed as is in the console It is the textual response to a CLI command All the console output is prefixed by target stream output is the output produced by the target program All the target output is prefixed by log stream output is output text coming from gdb s internals for instance messages that should be displayed as par...

Page 221: ... familiar with gdb s existing CLI interface gdb mi accepts existing CLI commands As specified by the syntax such commands can be directly entered into the gdb mi interface and gdb will respond This mechanism is provided as an aid to developers of gdb mi clients and not as a reliable interface into the CLI Since the command is being interpreteted in an environment that assumes gdb mi behaviour the ...

Page 222: ...ring output The console output stream contains text that should be displayed in the CLI console window It contains the textual responses to CLI commands string output The target output stream contains any textual output from the running target string output The log stream contains debugging messages being produced by gdb s internals 26 6 3 gdb mi Out of band Records Out of band records are used to...

Page 223: ...For each command in the block the following is described 26 7 3 1 Synopsis command args 26 7 3 2 gdb Command The corresponding gdb CLI command 26 7 3 3 Result The result 26 7 3 4 Out of band The out of band result 26 7 3 5 Notes The notes 26 7 3 6 Example An example 26 8 gdb mi Breakpoint table commands This section documents gdb mi commands for manipulating breakpoints 26 8 1 The break afterComma...

Page 224: ...le nr_rows 1 nr_cols 6 hdr width 3 alignment 1 col_name number colhdr Num width 14 alignment 1 col_name type colhdr Type width 4 alignment 1 col_name disp colhdr Disp width 3 alignment 1 col_name enabled colhdr Enb width 10 alignment 1 col_name addr colhdr Address width 40 alignment 2 col_name what colhdr What body bkpt number 1 type breakpoint disp keep enabled y addr 0x000100d0 func main file he...

Page 225: ...dr What body bkpt number 1 type breakpoint disp keep enabled y addr 0x000100d0 func main file hello c line 5 cond 1 times 0 ignore 3 gdb 26 8 3 The break deleteCommand 26 8 3 1 Synopsis break delete breakpoint Delete the breakpoint s whose number s are specified in the argument list This is obviously reflected in the breakpoint list 26 8 3 2 gdb command The corresponding gdb command is delete 26 8...

Page 226: ...onding gdb command is disable 26 8 4 3 Example gdb break disable 2 done gdb break list done BreakpointTable nr_rows 1 nr_cols 6 hdr width 3 alignment 1 col_name number colhdr Num width 14 alignment 1 col_name type colhdr Type width 4 alignment 1 col_name disp colhdr Disp width 3 alignment 1 col_name enabled colhdr Enb width 10 alignment 1 col_name addr colhdr Address width 40 alignment 2 col_name ...

Page 227: ...ent 1 col_name type colhdr Type width 4 alignment 1 col_name disp colhdr Disp width 3 alignment 1 col_name enabled colhdr Enb width 10 alignment 1 col_name addr colhdr Address width 40 alignment 2 col_name what colhdr What body bkpt number 2 type breakpoint disp keep enabled y addr 0x000100d0 func main file hello c line 5 times 0 gdb 26 8 6 The break infoCommand 26 8 6 1 Synopsis break info breakp...

Page 228: ...nal on condition i ignore count Initialize the ignore count r Insert a regular breakpoint in all the functions whose names match the given regular expression Other flags are not applicable to regular expresson 26 8 7 2 Result The result is in the form done bkptno number func funcname file filename line lineno where number is the gdb number for this breakpoint funcname is the name of the function w...

Page 229: ... enabled colhdr Enb width 10 alignment 1 col_name addr colhdr Address width 40 alignment 2 col_name what colhdr What body bkpt number 1 type breakpoint disp keep enabled y addr 0x0001072c func main file recursive2 c line 4 times 0 bkpt number 2 type breakpoint disp del enabled y addr 0x00010774 func foo file recursive2 c line 11 times 0 gdb break insert r foo int foo int int done bkpt number 3 add...

Page 230: ...lignment 1 col_name disp colhdr Disp width 3 alignment 1 col_name enabled colhdr Enb width 10 alignment 1 col_name addr colhdr Address width 40 alignment 2 col_name what colhdr What body bkpt number 1 type breakpoint disp keep enabled y addr 0x000100d0 func main file hello c line 5 times 0 bkpt number 2 type breakpoint disp keep enabled y addr 0x00010114 func foo file hello c line 13 times 0 gdb H...

Page 231: ...inserted 26 8 9 2 gdb Command The corresponding gdb commands are watch awatch and rwatch 26 8 9 3 Example Setting a watchpoint on a variable in the main function gdb break watch x done wpt number 2 exp x gdb exec continue running done reason watchpoint trigger wpt number 2 exp x value old 268439212 new 55 frame func main args file recursive2 c line 5 gdb Setting a watchpoint on a variable local to...

Page 232: ...c callee4 args file devo gdb testsuite gdb mi basics c line 13 gdb break list done BreakpointTable nr_rows 2 nr_cols 6 hdr width 3 alignment 1 col_name number colhdr Num width 14 alignment 1 col_name type colhdr Type width 4 alignment 1 col_name disp colhdr Disp width 3 alignment 1 col_name enabled colhdr Enb width 10 alignment 1 col_name addr colhdr Address width 40 alignment 2 col_name what colh...

Page 233: ...dr is the beginning address or pc end addr is the end address filename is the name of the file to disassemble linenum is the line number to disassemble around lines is the the number of disassembly lines to be produced If it is 1 the whole function will be dis assembled in case no end addr is specified If end addr is specified as a non zero value and lines is lower than the number of disassembly l...

Page 234: ...name main offset 8 inst sethi hi 0x11800 o2 address 0x000107c8 func name main offset 12 inst or o2 0x140 o1 t 0x11940 W _lib_version 8X address 0x000107cc func name main offset 16 inst sethi hi 0x11800 o2 address 0x000107d0 func name main offset 20 inst or o2 0x168 o4 t 0x11968 W _lib_version 48X gdb Disassemble the whole main function Line 32 is part of main data disassemble f basics c l 32 0 don...

Page 235: ...ess 0x000107bc func name main offset 0 inst save sp 112 sp src_and_asm_line line 32 file kwikemart marge ezannoni flathead dev devo gdb testsuite gdb mi basics c line_asm_insn address 0x000107c0 func name main offset 4 inst mov 2 o0 address 0x000107c4 func name main offset 8 inst sethi hi 0x11800 o2 gdb 26 9 2 The data evaluate expressionCommand 26 9 2 1 Synopsis data evaluate expression expr Eval...

Page 236: ...ta evaluate expression A 3 511 done value 4 gdb 26 9 3 The data list changed registersCommand 26 9 3 1 Synopsis data list changed registers Display a list of the registers that have changed 26 9 3 2 gdb Command gdb doesn t have a direct analog for this command gdbtk has the corresponding command gdb_changed_register_list 26 9 3 3 Example On a PPC MBX board gdb exec continue running gdb stopped rea...

Page 237: ... gdb_regnames 26 9 4 3 Example For the PPC MBX board 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 r19 r20 r21 r22 r23 r24 r25 r26 r27 r28 r29 r30 r31 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 f13 f14 f15 f16 f17 f18 f19 f20 f21 f22 f23 f24 f25 f26 f27 f28 f29 f30 f31 pc ps cr lr ctr xer gdb data list register names 1 2 3 done re...

Page 238: ...er 6 value 0x3fff58 number 7 value 0xfe011e98 number 8 value 0x2 number 9 value 0xfa202820 number 10 value 0xfa202808 number 11 value 0x1 number 12 value 0x0 number 13 value 0x4544 number 14 value 0xffdfffff number 15 value 0xffffffff number 16 value 0xfffffeff number 17 value 0xefffffed number 18 value 0xfffffffe number 19 value 0xffffffff number 20 value 0xffffffff number 21 value 0xffffffff num...

Page 239: ...e data read memoryCommand 26 9 6 1 Synopsis data read memory o byte offset address word format word size nr rows nr cols aschar where address An expression specifying the address of the first memory word to be read Complex expressions containing embedded white space should be quoted using the C convention word format The format to be used to print the memory words The notation is the same as for g...

Page 240: ...o 6 bytes 6 x 1 3 2 9 done addr 0x00001390 nr bytes 6 total bytes 6 next row 0x00001396 prev row 0x0000138e next page 0x00001396 prev page 0x0000138a memory addr 0x00001390 data 0x00 0x01 addr 0x00001392 data 0x02 0x03 addr 0x00001394 data 0x04 0x05 gdb Read two bytes of memory starting at address shorts 64 and display as a single word formatted in decimal gdb 5 data read memory shorts 64 d 2 1 1 ...

Page 241: ... 0x2d 0x2e 0x2f ascii gdb 26 9 7 The display deleteCommand 26 9 7 1 Synopsis display delete number Delete the display number 26 9 7 2 gdb Command The corresponding gdb command is delete display 26 9 7 3 Example N A 26 9 8 The display disableCommand 26 9 8 1 Synopsis display disable number Disable display number 26 9 8 2 gdb Command The corresponding gdb command is disable display 26 9 8 3 Example ...

Page 242: ...b command is enable display 26 9 9 3 Example N A 26 9 10 The display insertCommand 26 9 10 1 Synopsis display insert expression Display expression every time the program stops 26 9 10 2 gdb Command The corresponding gdb command is display 26 9 10 3 Example N A 26 9 11 The display listCommand 26 9 11 1 Synopsis display list List the displays Do not show the current values ...

Page 243: ...n is used the search path is reset to the default search path If directories pathdir are supplied in addition to the r option the search path is first reset and then addition occurs as normal Multiple directories may be specified separated by blanks Specifying multiple directories in a single command results in the directories added to the beginning of the search path in the same order they were p...

Page 244: ...the original search path that existed at gdb start up If directories pathdir are supplied in addition to the r option the search path is first reset and then addition occurs as normal Multiple directories may be specified separated by blanks Specifying multiple directories in a single command results in the directories added to the beginning of the search path in the same order they were presented...

Page 245: ...ry 26 9 15 2 gdb command The corresponding gdb command is pwd 26 9 15 3 Example gdb environment pwd done cwd kwikemart marge ezannoni flathead dev devo gdb gdb 26 10 gdb mi Program control 26 10 1 Program termination As a result of execution the inferior program can run to completion if it doesn t encounter any breakpoints In this case the output will include an exit code if the program has exited...

Page 246: ...s a signal such as SIGINT In this case gdb mi displays this gdb stopped reason exited signalled signal name SIGINT signal meaning Interrupt 26 11 Command Descriptions The following sections describe various commands 26 11 1 The exec abortCommand 26 11 1 1 Synopsis exec abort Kill the inferior running program 26 11 1 2 gdb Command The corresponding gdb command is kill 26 11 1 3 Example N A 26 11 2 ...

Page 247: ...round 26 11 3 The exec continueCommand 26 11 3 1 Synopsis exec continue Asynchronous command Resumes the execution of the inferior program until a breakpoint is encoun tered or until the inferior exits 26 11 3 2 gdb Command The corresponding gdb corresponding is continue 26 11 3 3 Example exec continue running gdb Hello world stopped reason breakpoint hit bkptno 2 frame func foo args file hello c ...

Page 248: ...f the internal gdb variable storing the result is printed together with the value itself exec finish running gdb stopped reason function finished frame addr 0x000107b0 func foo args name a value 1 name b value 9 file recursive2 c line 14 gdb result var 1 return value 0 gdb 26 11 5 The exec interruptCommand 26 11 5 1 Synopsis exec interrupt Asynchronous command Interrupts the background execution o...

Page 249: ...10140 func foo args file try c line 13 gdb gdb exec interrupt error msg mi_cmd_exec_interrupt Inferior not executing gdb 26 11 6 The exec nextCommand 26 11 6 1 Synopsis exec next Asynchronous command Resumes execution of the inferior program stopping when the beginning of the next source line is reached 26 11 6 2 gdb Command The corresponding gdb command is next 26 11 6 3 Example exec next running...

Page 250: ...on in the middle of a source line the address will be printed as well 26 11 7 2 gdb Command The corresponding gdb command is nexti 26 11 7 3 Example gdb exec next instruction running gdb stopped reason end stepping range addr 0x000100d4 line 5 file hello c gdb 26 11 8 The exec returnCommand 26 11 8 1 Synopsis exec return Makes current function return immediately Doesn t execute the inferior Displa...

Page 251: ... callee3 args name strarg value 0x11940 A string argument file devo gdb testsuite gdb mi basics c line 18 gdb 26 11 9 The exec runCommand 26 11 9 1 Synopsis exec run Asynchronous command Starts execution of the inferior from the beginning The inferior executes until either a breakpoint is encountered or the program exits 26 11 9 2 gdb Command The corresponding gdb command is run 26 11 9 3 Example ...

Page 252: ...is exec step Asynchronous command Resumes execution of the inferior program stopping when the beginning of the next source line is reached if the next source line is not a function call If it is stop at the first instruction of the called function 26 11 11 2 gdb Command The corresponding gdb command is step 26 11 11 3 Example Stepping into a function exec step running gdb stopped reason end steppi...

Page 253: ...stopped will vary depending on whether we have stopped in the middle of a source line or not In the former case the address at which the program stopped will be printed as well 26 11 12 2 gdb Command The corresponding gdb command is stepi 26 11 12 3 Example gdb exec step instruction running gdb stopped reason end stepping range frame func foo args file try c line 10 gdb exec step instruction runni...

Page 254: ...gdb exec until recursive2 c 6 running gdb x 55 stopped reason location reached frame func main args file recursive2 c line 6 gdb 26 11 14 The file exec and symbolsCommand 26 11 14 1 Synopsis file exec and symbols file Specify the executable file to be debugged This file is the one from which the symbol table is also read If no file is specified the command clears the executable and symbol informat...

Page 255: ...mbols the symbol table is not read from this file If used without argument gdb clears the information about the executable file No output is produced except a completion notification 26 11 15 2 gdb Command The corresponding gdb command is exec file 26 11 15 3 Example gdb file exec file kwikemart marge ezannoni TRUNK mbx hello mbx done gdb 26 11 16 The file list exec sectionsCommand 26 11 16 1 Syno...

Page 256: ...le list exec source file List the line number the current source file and the absolute path to the current source file for the current executable 26 11 17 2 gdb Command There s no gdb command which directly corresponds to this one 26 11 17 3 Example gdb 123 file list exec source file 123 done line 1 file foo c fullname home bar foo c gdb 26 11 18 The file list exec source filesCommand 26 11 18 1 S...

Page 257: ...ist shared librariesCommand 26 11 19 1 Synopsis file list shared libraries List the shared libraries in the program 26 11 19 2 gdb Command The corresponding gdb command is info shared 26 11 19 3 Example N A 26 11 20 The file list symbol filesCommand 26 11 20 1 Synopsis file list symbol files List symbol files 26 11 20 2 gdb Command The corresponding gdb command is info file part of it 26 11 20 3 E...

Page 258: ...symbol table info No output is produced except for a completion notification 26 11 21 2 gdb Command The corresponding gdb command is symbol file 26 11 21 3 Example gdb file symbol file kwikemart marge ezannoni TRUNK mbx hello mbx done gdb 26 12 Miscellaneous gdb commands in gdb mi 26 12 1 The gdb exitCommand 26 12 1 1 Synopsis gdb exit Exit gdb immediately 26 12 1 2 gdb Command Approximately corre...

Page 259: ...Synopsis gdb set Set an internal gdb variable 26 12 2 2 gdb Command The corresponding gdb command is set 26 12 2 3 Example gdb gdb set foo 3 done gdb 26 12 3 The gdb showCommand 26 12 3 1 Synopsis gdb show Show the current value of a gdb variable 26 12 3 2 gdb command The corresponding gdb command is show ...

Page 260: ...hen you start an inter active session 26 12 4 3 Example 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 it under certain conditions Type show copying to see the conditions There is absolutely no warranty for GDB Type show warranty for details This GD...

Page 261: ...uring symbol reading couldn t parse type debugger out of date n During symbol reading bad structure type format n Breakpoint 1 at 0x8074fc6 file src gdb main c line 743 n done gdb 26 13 gdb mi Stack Manipulation Commands 26 13 1 The stack info frameCommand 26 13 1 1 Synopsis stack info frame Get info on the current frame 26 13 1 2 gdb Command The corresponding gdb command is info frame or frame wi...

Page 262: ... info depth 12 done depth 12 gdb stack info depth 11 done depth 11 gdb stack info depth 13 done depth 12 gdb 26 13 3 The stack list argumentsCommand 26 13 3 1 Synopsis stack list arguments show values low frame high frame Display a list of the arguments for the frames between low frame and high frame inclusive If low frame and high frame are not provided list the arguments for the whole call stack...

Page 263: ...r 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 1 args name strarg frame level 2 args name intarg name strarg frame level 3 args name intarg name strarg name fltarg frame level 4 args gdb stack list arguments 1 done stack args frame level 0 args frame level 1 args name strarg value 0x11940 A string arg...

Page 264: ...ger arguments it shows the frames whose levels are between the two arguments inclusive If the two arguments are equal it shows the single frame at the corresponding level 26 13 4 2 gdb Command The corresponding gdb commands are backtrace and where 26 13 4 3 Example Full stack backtrace gdb stack list frames done stack frame level 0 addr 0x0001076c func foo file recursive2 c line 11 frame level 1 a...

Page 265: ... and high_frame gdb stack list frames 3 5 done stack frame level 3 addr 0x000107a4 func foo file recursive2 c line 14 frame level 4 addr 0x000107a4 func foo file recursive2 c line 14 frame level 5 addr 0x000107a4 func foo file recursive2 c line 14 gdb Show a single frame gdb stack list frames 3 3 done stack frame level 3 addr 0x000107a4 func foo file recursive2 c line 14 gdb 26 13 5 The stack list...

Page 266: ... name B value 2 name C value 3 gdb 26 13 6 The stack select frameCommand 26 13 6 1 Synopsis stack select frame framenum Change the current frame Select a different frame framenum on the stack 26 13 6 2 gdb Command The corresponding gdb commands are frame up down select frame up silent and down silent 26 13 6 3 Example gdb stack select frame 2 done gdb 26 14 gdb mi Symbol Query Commands 26 14 1 The...

Page 267: ...and is info address 26 14 1 3 Example N A 26 14 2 The symbol info fileCommand 26 14 2 1 Synopsis symbol info file Show the file for the symbol 26 14 2 2 gdb Command There s no equivalent gdb command gdbtk has gdb_find_file 26 14 2 3 Example N A 26 14 3 The symbol info functionCommand 26 14 3 1 Synopsis symbol info function Show which function the symbol lives in ...

Page 268: ...e addresses of the code for a source line 26 14 4 2 gdb Command The corresponding gdb comamnd is info line gdbtk has the gdb_get_line and gdb_get_file commands 26 14 4 3 Example N A 26 14 5 The symbol info symbolCommand 26 14 5 1 Synopsis symbol info symbol addr Describe what symbol is at location addr 26 14 5 2 gdb Command The corresponding gdb command is info symbol 26 14 5 3 Example N A ...

Page 269: ...mple N A 26 14 7 The symbol list linesCommand 26 14 7 1 Synopsis symbol list lines filename Print the list of lines that contain code and their associated program addresses for the given source filename The entries are sorted in ascending PC order 26 14 7 2 gdb Command There is no corresponding gdb command 26 14 7 3 Example gdb symbol list lines basics c done lines pc 0x08048554 line 7 pc 0x080485...

Page 270: ... are info types in gdb gdb_search in gdbtk 26 14 8 3 Example N A 26 14 9 The symbol list variablesCommand 26 14 9 1 Synopsis symbol list variables List all the global and static variable names 26 14 9 2 gdb Command info variables in gdb gdb_search in gdbtk 26 14 9 3 Example N A 26 14 10 The symbol locateCommand 26 14 10 1 Synopsis symbol locate ...

Page 271: ...ble Show type of variable 26 14 11 2 gdb Command The corresponding gdb command is ptype gdbtk has gdb_obj_variable 26 14 11 3 Example N A 26 15 gdb mi Target Manipulation Commands 26 15 1 The target attachCommand 26 15 1 1 Synopsis target attach pid file Attach to a process pid or a file file outside of gdb 26 15 1 2 gdb command The corresponding gdb command is attach ...

Page 272: ...n on target to the exec file Without the argument all sections are compared 26 15 2 2 gdb Command The gdb equivalent is compare sections 26 15 2 3 Example N A 26 15 3 The target detachCommand 26 15 3 1 Synopsis target detach Disconnect from the remote target There s no output 26 15 3 2 gdb command The corresponding gdb command is detach 26 15 3 3 Example gdb target detach done gdb ...

Page 273: ... gdb target disconnect done gdb 26 15 5 The target downloadCommand 26 15 5 1 Synopsis target download Loads the executable onto the remote target It prints out an update message every 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 section section size The size of the section total sent The total size of what was sen...

Page 274: ...on sent 1024 section size 6668 total sent 1024 total size 9880 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 section sent 2560 section size 6668 total sent 2560 total size 9880 download section text section sent 3072 section size 6668 total sen...

Page 275: ...on sent 2048 section size 3156 total sent 8772 total size 9880 download section data section sent 2560 section size 3156 total sent 9284 total size 9880 download section data section sent 3072 section size 3156 total sent 9796 total size 9880 done address 0x10004 load size 9880 transfer rate 6586 write rate 429 gdb 26 15 6 The target exec statusCommand 26 15 6 1 Synopsis target exec status Provide...

Page 276: ...rent targetsCommand 26 15 8 1 Synopsis target list current targets Describe the current target 26 15 8 2 gdb Command The corresponding information is printed by info file among other things 26 15 8 3 Example N A 26 15 9 The target list parametersCommand 26 15 9 1 Synopsis target list parameters 26 15 9 2 gdb Command No equivalent 26 15 9 3 Example N A ...

Page 277: ... and the like Refer to Section 18 2 Commands for managing targets for more details The output is a connection notification followed by the address at which the target program is in the following form connected addr address func function name args arg list 26 15 10 2 gdb Command The corresponding gdb command is target 26 15 10 3 Example gdb target select async dev ttya connected addr 0xfe00a300 fun...

Page 278: ...psis thread list all threads 26 16 2 2 gdb Command The equivalent gdb command is info threads 26 16 2 3 Example N A 26 16 3 The thread list idsCommand 26 16 3 1 Synopsis 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 26 16 3 2 gdb Command Part of info threads supplies the same information ...

Page 279: ...nopsis thread select threadnum Make threadnum the current thread It prints the number of the new current thread and the topmost frame for that thread 26 16 4 2 gdb Command The corresponding gdb command is thread 26 16 4 3 Example gdb exec next running gdb stopped reason end stepping range thread id 2 line 187 file devo gdb testsuite gdb threads linux dp c gdb thread list ids done thread ids thread...

Page 280: ...least the following operations gdb show output radix stack list arguments stack list locals stack select frame 26 18 2 Introduction to Variable Objects in gdb mi The basic idea behind variable objects is the creation of a named object to represent a variable an expression a memory location or even a CPU register For each object created a set of operations is available for examining or changing its...

Page 281: ...n be used 26 18 3 Description And Use of Operations on Variable Objects This section describes the use of operations on variable objects 26 18 4 The var createCommand 26 18 4 1 Synopsis var create name frame addr expression This operation creates a variable object which allows the monitoring of a variable the result of an expression a memory cell or a CPU register The name parameter is the string ...

Page 282: ...8 5 The var deleteCommand 26 18 5 1 Synopsis var delete name Deletes a previously created variable object and all of its children Returns an error if the object name is not found 26 18 6 The var set formatCommand 26 18 6 1 Synopsis var set format name format spec Sets the output format for the value of the object name to be format spec The syntax for the format spec is as follows format spec binar...

Page 283: ...o num childrenCommand 26 18 8 1 Synopsis var info num children name Returns the number of children of a variable object name numchild n 26 18 9 The var list childrenCommand 26 18 9 1 Synopsis var list children name Returns a list of the children of the specified variable object numchild n children name name numchild n type type repeats N times 26 18 10 The var info typeCommand ...

Page 284: ...The var info expressionCommand 26 18 11 1 Synopsis var info expression name Returns what is represented by the variable object name lang lang spec exp expression where lang spec is C C Java 26 18 12 The var show attributes Command 26 18 12 1 Synopsis var show attributes name List attributes of the specified variable object name status attr attr where attr is editable noneditable TBD 26 18 13 The v...

Page 285: ...alue of a child variable can be evaluated 26 18 14 The var assignCommand 26 18 14 1 Synopsis var assign name expression Assigns the value of expression to the variable object specified by name The object must be editable If the variable s value is altered by the assign the variable will show up in any subse quent var update list 26 18 14 2 Example gdb var assign var1 3 done value 3 gdb var update ...

Page 286: ...r 26 The gdb mi Interface Update the value of the variable object name by evaluating its expression after fetching all the new values from memory or registers A causes all existing variable objects to be updated ...

Page 287: ... annotation which means those three characters as output A simple example of starting up gdb with annotations is gdb annotate 2 GNU GDB 5 0 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 it under certain conditions Type show copying to see the conditions There is absolutely no w...

Page 288: ...e output command the annotation is similar Z Zvalue begin value flags the value Z Zvalue end When gdb prints an argument to a function for example in the output from the backtrace com mand it annotates it as follows Z Zarg begin argument name Z Zarg name end separator string Z Zarg value value flags the value Z Zarg end where argument name is the name of the argument separator string is text which...

Page 289: ... repetitions is the number of consec utive array elements which contain that value and repetition string is a string which is designed to convey to the user that repetition is being depicted Once all the array elements have been output the array annotation is ended with Z Zarray section end 27 4 Frames Whenever gdb prints a frame it annotates it For example this applies to frames printed when gdb ...

Page 290: ...printed in a form which is intended for user consumption in particular the syntax varies depending on the language and separator string is a string intended to separate this address from what follows for the user s benefit Then comes Z Zframe function name function name Z Zframe args arguments where function name is the name of the function executing in the frame or if not known and arguments are ...

Page 291: ...ludes information such as the size format or other information about how the value is being displayed expression is the expression being displayed expression separator is intended to separate the expression from the text that follows for the user and value is the actual value being displayed 27 6 Annotation for gdb Input When gdb prompts for input it annotates this fact so it is possible to know w...

Page 292: ... responds to an interrupt Z Zerror This annotation occurs right before gdb responds to an error Quit and error annotations indicate that any annotations which gdb was in the middle of may end abruptly For example if a value history begin annotation is followed by a error one cannot expect to receive the matching value history end One cannot expect not to receive it either however an error annotati...

Page 293: ...type Z Zfield 2 disposition Z Zfield 3 enable Z Zfield 4 address Z Zfield 5 what Z Zfield 6 frame Z Zfield 7 condition Z Zfield 8 ignore count Z Zfield 9 commands Note that address is intended for user consumption the syntax varies depending on the language The output ends with Z Zbreakpoints table end 27 9 Invalidation Notices The following annotations say that certain pieces of state may have ch...

Page 294: ... name end middle text Z Zsignal string string Z Zsignal string end end text where name is the name of the signal such as SIGILL or SIGSEGV and string is the explana tion of the signal such as Illegal Instruction or Segmentation fault intro text middle text and end text are for the user s benefit and have no particular format Z Zsignal The syntax of this annotation is just like signalled but gdb is...

Page 295: ... beginning of the line and addr is the address in the target program associated with the source which is being displayed addr is in the form 0x followed by one or more lowercase hex digits note that this does not depend on the language 27 12 Annotations We Might Want in the Future target invalid the target might have changed registers heap contents or execution status For performance we might even...

Page 296: ...286 Chapter 27 gdb Annotations ...

Page 297: ...f you obtained gdb from a support organization we recommend you contact that organization first You can find contact information for many support companies and individuals in the file etc SERVICE in the gnu Emacs distribution In any event we also recommend that you submit bug reports for gdb The prefered method is to sub mit them directly using http www gnu org software gdb bugs gdb s Bugs web pag...

Page 298: ...ou gave the compiler to compile your example and observe the bug For example did you use O To guarantee you will not omit something important list them all A copy of the Makefile or the output from make is sufficient If we were to try to guess the arguments we would probably guess wrong and then we might not encounter the bug A complete input script and all necessary source files that will reprodu...

Page 299: ... a good one But do not omit the necessary information such as the test case on the assumption that a patch is all we need We might see problems with your patch and decide to fix the problem another way or we might not understand it at all Sometimes with a program as complicated as gdb it is very hard to construct an example that will make the program follow a certain path through the code If you d...

Page 300: ...290 Chapter 28 Reporting Bugs in gdb ...

Page 301: ...r Enter on some keyboards 29 2 Readline Interaction Often during an interactive session you type in a long line of text only to notice that the first word on the line is misspelled The Readline library gives you a set of commands for manipulating the text as you type it in allowing you to just fix your typo and not forcing you to retype the majority of the line Using these editing commands you mov...

Page 302: ...rather than the character to the left of the cursor 29 2 2 Readline Movement Commands The above table describes the most basic keystrokes that you need in order to do editing of the input line For your convenience many other commands have been added in addition to C b C f C d and DEL Here are some commands for moving more rapidly about the line C a Move to the start of the line C e Move to the end...

Page 303: ...vious word Word boundaries are the same as those used by M b C w Kill from the cursor to the previous whitespace This is different than M DEL because the word boundaries differ Here is how to yank the text back into the line Yanking means to copy the most recently killed text from the kill buffer C y Yank the most recently killed text back into the buffer at the cursor M y Rotate the kill ring and...

Page 304: ...e the last line found the current line and begin editing Readline remembers the last incremental search string If two C rs are typed without any intervening characters defining a new search string any remembered search string is used Non incremental searches read the entire search string before starting to search for matching history lines The search string may be typed by the user or be part of t...

Page 305: ...0 The default limit is 100 convert meta If set to on Readline will convert characters with the eighth bit set to an ascii key sequence by stripping the eighth bit and prefixing an ESC character converting them to a meta prefixed key sequence The default value is on disable completion If set to On Readline will inhibit word completion Completion characters will be inserted into the line as if they ...

Page 306: ...ffects the default keymap mark directories If set to on completed directory names have a slash appended The default is on mark modified lines This variable when set to on causes Readline to display an asterisk at the start of history lines which have been modified This variable is off by default mark symlinked directories If set to on completed names which are symbolic links to directories have a ...

Page 307: ...pressed a macro keyname function name or macro keyname is the name of a key spelled out in English For example Control u universal argument Meta Rubout backward kill word Control o Z output In the above example C u is bound to the function universal argument M DEL is bound to the function backward kill word and C o is bound to run the macro ex pressed on the right hand side that is to insert the t...

Page 308: ...eight bit character whose value is the octal value nnn one to three digits xHH the eight bit character whose value is the hexadecimal value HH one or two hex digits When entering the text of a macro single or double quotes must be used to indicate a macro definition Unquoted text is assumed to be a function name In the macro body the backslash escapes described above are expanded Backslash will qu...

Page 309: ... the right side of the is tested against both the full name of the terminal and the portion of the terminal name before the first This allows sun to match both sun and sun cmd for instance application The application construct is used to include application specific settings Each program using the Readline library sets the application name and you can test for a particular value This could be used...

Page 310: ...ard char M OC forward char M OA previous history M OB next history Arrow keys in ANSI mode M D backward char M C forward char M A previous history M B next history Arrow keys in 8 bit keypad mode M C OD backward char M C OC forward char M C OA previous history M C OB next history Arrow keys in 8 bit ANSI mode M C D backward char M C C forward char M C A previous history M C B next history C q quot...

Page 311: ... set directly rather than as meta prefixed characters set output meta on if there are more than 150 possible completions for a word ask the user if he wants to see all of them set completion query items 150 For FTP if Ftp C xg get M C xt put M M yank last arg endif 29 4 Bindable Readline Commands This section describes Readline commands that may be bound to key sequences Command names without an a...

Page 312: ... add_history If this line is a modified history line the history line is restored to its original state previous history C p Move back through the history list fetching the previous command next history C n Move forward through the history list fetching the next command beginning of history M Move to the first line in the history end of history M Move to the end of the input history i e the line c...

Page 313: ...serts the nth word from the end of the previous command yank last arg M or M _ Insert last argument to the previous command the last word of the previous history entry With an argument behave exactly like yank nth arg Successive calls to yank last arg move back through the history list inserting the last argument of each line in turn 29 4 3 Commands For Changing Text delete char C d Delete the cha...

Page 314: ...previous word but do not move the cursor overwrite mode Toggle overwrite mode With an explicit positive numeric argument switches to overwrite mode With an explicit non positive numeric argument switches to insert mode This command affects only emacs mode vi mode does overwrite differently Each call to readline starts in insert mode In overwrite mode characters bound to self insert replace the tex...

Page 315: ...s command is unbound yank C y Yank the top of the kill ring into the buffer at point yank pop M y Rotate the kill ring and yank the new top You can only do this if the prior command is yank or yank pop 29 4 5 Specifying Numeric Arguments digit argument M 0 M 1 M Add this digit to the argument already accumulating or start a new argument M starts a negative argument universal argument This is anoth...

Page 316: ...itions forward in the list of matches a negative argument may be used to move backward through the list This command is intended to be bound to TAB but is unbound by default delete char or list Deletes the character under the cursor if not at the beginning or end of the line like delete char If at the end of the line behaves identically to possible completions This command is unbound by default 29...

Page 317: ...ount searches for previous occurrences character search backward M C A character is read and point is moved to the previous occurrence of that character A negative count searches for subsequent occurrences insert comment M Without a numeric argument the value of the comment begin variable is inserted at the begin ning of the current line If a numeric argument is supplied this command acts as a tog...

Page 318: ...adline library does not have a full set of vi editing functions it does contain enough to allow simple editing of the line The Readline vi mode behaves as specified in the posix 1003 2 standard In order to switch interactively between emacs and vi editing modes use the command M C j bound to emacs editing mode when in vi mode and to vi editing mode in emacs mode The Read line default is emacs mode...

Page 319: ... selected from the history is called the event and the portions of that line that are acted upon are called words Various modifiers are available to manipulate the selected words The line is broken into words in the same fashion that Bash does so that several words surrounded by quotes are considered one word History expansions are introduced by the appearance of the history expansion character wh...

Page 320: ...receding command When you type this the preceding command is repeated in toto designates the last argument of the preceding command This may be shortened to fi 2 designates the second argument of the most recent command starting with the letters fi Here are the word designators 0 zero The 0th word For many applications this is the command word n The nth word The first argument that is word 1 The l...

Page 321: ...aving the tail r Remove a trailing suffix of the form suffix leaving the basename e Remove all but the trailing suffix p Print the new command but do not execute it s old new Substitute new for the first occurrence of old in the event line Any delimiter may be used in place of The delimiter may be quoted in old and new with a single backslash If appears in new it is replaced by old A single backsl...

Page 322: ...312 Chapter 30 Using History Interactively ...

Page 323: ...y If necessary you can print out these files or read them with any editor but they are easier to read using the info subsystem in gnu Emacs or the standalone info program available as part of the gnu Texinfo distribution If you want to format these Info files yourself you need one of the Info formatting programs such as texinfo format buffer or makeinfo If you have makeinfo installed and are in th...

Page 324: ...TeX and a dvi printer program installed you can typeset and print this manual First switch to the the gdb subdirectory of the main source directory for example to gdb 2003 07 22 cvs gdb and type make gdb dvi Then give gdb dvi to your dvi printing program ...

Page 325: ...ary File Descriptor library gdb 2003 07 22 cvs include gnu include files gdb 2003 07 22 cvs libiberty source for the liberty free software library gdb 2003 07 22 cvs opcodes source for the library of opcode tables and disassemblers gdb 2003 07 22 cvs readline source for the gnu command line interface gdb 2003 07 22 cvs glob source for the gnu filename pattern matching subroutine gdb 2003 07 22 cvs...

Page 326: ... subdirectory This leads to build errors about missing include files such as bfd bfd h You can install gdb anywhere it has no hardwired paths However you should make sure that the shell on your path named by the SHELL environment variable is publicly readable Remember that gdb uses the shell to start your program some systems refuse to let gdb debug child processes whose programs are not readable ...

Page 327: ...ries and then build GDB When you have multiple hosts or targets configured in separate directories you can run make on them in parallel for example if they are NFS mounted on each of the hosts they will not interfere with each other B 2 Specifying names for hosts and targets The specifications used for hosts and targets in the configure script are based on a three part naming scheme but some short...

Page 328: ...figurations in directories separate from the gdb source direc tories Among other things you can use this to build or maintain several configurations simul taneously in separate directories configure writes configuration specific files in the current directory but arranges for them to use the source in the directory dirname configure creates directories under the working directory in parallel to th...

Page 329: ...point at the target of a longjmp until Temporary internal breakpoint used by the gdb until command finish Temporary internal breakpoint used by the gdb finish command shlib events Shared library events maint internal error maint internal warning Cause gdb to call the internal function internal_error or internal_warning and hence behave as though an internal error or internal warning has been detec...

Page 330: ...rs and the command maint print register groups includes the groups that each register is a member of Takes an optional file parameter maint print reggroups Print gdb s internal register group data structures Takes an optional file parameter gdb maint print reggroups Group Type general user float user all user vector user system user save internal restore internal maint set profile maint show profi...

Page 331: ...ded since gdb 5 0 must not accept sequence id When either the host or the target machine receives a packet the first response expected is an acknowl edgment either to indicate the package was received correctly or to request retransmission packet data checksum The host gdb sends commands and the target the debugging stub incorporated in your program sends a response In the case of step and continu...

Page 332: ...A stub is required to support the g G m M c and s commands All other commands are optional D 2 Packets The following table provides a complete list of all currently defined commands and their corresponding response data extended mode Enable extended mode In extended mode the remote server is made persistent The R packet is used to restart the program being debugged Reply OK The remote target both ...

Page 333: ...ontinue addr is address to resume If addr is omitted resume at current address Reply refer to Section D 3 Stop Reply Packets for the reply specifications Csig addr continue with signal Continue with signal sig hex signal number If addr is omitted resume at same address Reply refer to Section D 3 Stop Reply Packets for the reply specifications d toggle debug deprecated Toggle debug flag D detach De...

Page 334: ...pecified below ENN for an error GXX write regs Reply OK for success ENN for an error h reserved Reserved for future use Hct set thread Set thread for subsequent operations m M g G et al c depends on the operation to be per formed it should be c for step and continue operations g for other operations The thread desig nator t may be 1 meaning all the threads a thread number or zero which means pick ...

Page 335: ...y starting at address addr Neither gdb nor the stub assume that sized memory transfers are assumed using word aligned accesses FIXME A word aligned mem ory transfer mechanism is needed Reply XX XX is mem contents Can be fewer bytes than requested if able to read only part of the data Neither gdb nor the stub assume that sized memory transfers are assumed using word aligned accesses FIXME A word al...

Page 336: ... r which contains two hex digits for each byte in the register target byte order Reply OK for success ENN for an error qquery general query Request info about query In general gdb queries have a leading upper case letter Custom vendor queries should use a company prefix in lower case ex qfsf var query may optionally be followed by a or separated list Stubs must ensure that they match the full quer...

Page 337: ...esume If addr is omitted resume at same address Reply refer to Section D 3 Stop Reply Packets for the reply specifications Ssig addr step with signal Like C but step not continue Reply refer to Section D 3 Stop Reply Packets for the reply specifications taddr PP MM search Search backwards starting at address addr for a match with pattern PP and mask MM PP and MM are 4 bytes addr must be at least 3...

Page 338: ...bytes Each breakpoint and watchpoint packet type is documented separately Implementation notes A remote target shall return an empty string for an unrecognized break point or watchpoint packet type A remote target shall support either both or neither of a given Ztype and ztype packet pair To avoid potential problems with duplicate packets the operations should be implemented in an idempotent way z...

Page 339: ... Z1 addr length insert hardware breakpoint draft Insert Z1 or remove z1 a hardware breakpoint at address addr of size length A hardware breakpoint is implemented using a mechanism that is not dependant on being able to modify the target s memory Implementation note A hardware breakpoint is not affected by code movement Reply OK success not supported ENN for an error z2 addr length remove write wat...

Page 340: ...C c S and s packets that reply is only returned when the target halts In the below the exact meaning of signal number is poorly defined In general one of the UNIX signal numbering conventions is used SAA AA is the signal number TAAn r n r n r AA two hex digit signal number n register number hex r target byte ordered register contents size defined by REGISTER_RAW_SIZE n thread r thread process ID t...

Page 341: ...list of parameters as defined for this very system call The target replies with this packet when it expects gdb to call a host system call on behalf of the target gdb replies with an appropriate F packet and keeps up waiting for the next reply packet from the target The latest C c S or s action is expected to be continued Refer to Section D 7 File I O remote protocol extension for more details D 4...

Page 342: ... is a hex encoding of ascii data comprising the printable string containing the extra information about the thread s attributes qLstartflagthreadcountnextthread query LIST or threadLIST deprecated Obtain thread information from RTOS Where startflag one hex digit is one to indicate the first query and zero to indicate a subsequent query threadcount two hex digits is the max imum number of threads t...

Page 343: ...emote c remote_unpack_thread_info_response qRcmd command remote command command hex encoded is passed to the local interpreter for execution Invalid commands should be reported using the output string Before the final result packet the target may also respond with a number of intermediate Ooutput console output packets Implementors should note that providing access to a stubs s interpreter may hav...

Page 344: ... continue to supply the values of symbols if available until the target ceases to request them D 5 Register Packet Format The following g G packets have previously been defined In the below some thirty two bit registers are transferred as sixty four bits Those registers should be zero sign extended which to fill the space allocated Register bytes are transfered in target byte order The two nibbles...

Page 345: ...he unified protocol values when data is transmitted The communication is synchronous A system call is possible only when GDB is waiting for the C c S or s packets While gdb handles the request for a system call the target is stopped to allow deterministic access to the target s memory Therefore File I O is not interuptible by target signals It is possible to interrupt File I O by a user interrupt ...

Page 346: ...types are coerced into the host types gdb calls the system call It then coerces datatypes back to protocol representation If pointer parameters in the request packet point to buffer space in which a system call is expected to copy data to the data is transmitted to the target using a M or X packet This packet has to be expected by the target implementation and is handled as any other M or X packet...

Page 347: ... with a break message and return to gdb with a T02 packet In this case it s important for the target to know in which state the system call was interrupted Since this action is by design not an atomic operation we have to differ between two cases The system call hasn t been performed on the host yet The system call on the host has been finished These two states can be distinguished by the target b...

Page 348: ...ttached to the gdb console 0 otherwise Implementing through system calls would require implementing ioctl and would be more complex than needed D 7 9 The system 3 call The other special case in this protocol is the system call which is implemented as it s own call too gdb is taking over the full task of calling the necessary host calls to perform the system call The return value of system is simpl...

Page 349: ...e already exists it is an error and open fails O_TRUNC If the file already exists and the open mode allows writing O_RDWR or O_WRONLY is given it will be truncated to length 0 O_APPEND The file is opened in append mode O_RDONLY The file is opened for reading only O_WRONLY The file is opened for writing only O_RDWR The file is opened for reading and writing Each other bit is silently ignored mode i...

Page 350: ...not allowed ENAMETOOLONG pathname was too long ENOENT A directory component in pathname does not exist ENODEV pathname refers to a device pipe named pipe or socket EROFS pathname refers to a file on a read only filesystem and write access was requested EFAULT pathname is an invalid pointer value ENOSPC No space on device to create the file EMFILE The process already has the maximum number of files...

Page 351: ...l was interrupted by the user D 7 10 3 read Synopsis int read int fd void buf unsigned int count Request Fread fd bufptr count Return value On success the number of bytes read is returned Zero indicates end of file If count is zero read returns zero as well On error 1 is returned Errors EBADF fd is not a valid file descriptor or is not open for reading EFAULT buf is an invalid pointer value EINTR ...

Page 352: ...a valid file descriptor or is not open for writing EFAULT buf is an invalid pointer value EFBIG An attempt was made to write a file that exceeds the host specific maximum file size allowed ENOSPC No space on device to write the data EINTR The call was interrupted by the user D 7 10 5 lseek Synopsis long lseek int fd long offset int flag Request Flseek fd offset flag flag is one of SEEK_SET The off...

Page 353: ...he gdb console EINVAL flag is not a proper value EINTR The call was interrupted by the user D 7 10 6 rename Synopsis int rename const char oldpath const char newpath Request Frename oldpathptr len newpathptr len Return value On success zero is returned On error 1 is returned Errors EISDIR newpath is an existing directory but oldpath is not a directory EEXIST newpath is a non empty directory EBUSY ...

Page 354: ...y component in oldpath or newpath does not exist EROFS The file is on a read only filesystem ENOSPC The device containing the file has no room for the new directory entry EINTR The call was interrupted by the user D 7 10 7 unlink Synopsis int unlink const char pathname Request Funlink pathnameptr len Return value On success zero is returned On error 1 is returned Errors EACCES No access to the fil...

Page 355: ...he user D 7 10 8 stat fstat Synopsis int stat const char pathname struct stat buf int fstat int fd struct stat buf Request Fstat pathnameptr len bufptr Ffstat fd bufptr Return value On success zero is returned On error 1 is returned Errors EBADF fd is not a valid open file ENOENT A directory component in pathname does not exist or the path is an empty string ENOTDIR A component of the path is not ...

Page 356: ... timeval tv void tz Request Fgettimeofday tvptr tzptr Return value On success 0 is returned 1 otherwise Errors EINVAL tz is a non NULL pointer EFAULT tvptr and or tzptr is an invalid pointer value D 7 10 10 isatty Synopsis int isatty int fd Request Fisatty fd Return value Returns 1 if fd refers to the gdb console 0 otherwise Errors EINTR The call was interrupted by the user ...

Page 357: ...ng unsigned long mode_t and time_t Int unsigned int mode_t and time_t are implemented as 32 bit values in this protocol Long and unsigned long are implemented as 64 bit types Refer to Section D 7 12 5 Limits for corresponding MIN and MAX values similar to those in limits h to allow range checking on host and target time_t datatypes are defined as seconds since the Epoch All integral datatypes tran...

Page 358: ...number of blocks allocated time_t st_atime time of last access time_t st_mtime time of last modification time_t st_ctime time of last change The integral datatypes are conforming to the definitions given in the approriate section refer to Section D 7 11 1 Integral datatypes for details so this structure is of size 64 bytes The values of several fields have a restricted meaning and or range of valu...

Page 359: ...al datatypes are conforming to the definitions given in the approriate section refer to Section D 7 11 1 Integral datatypes for details so this structure is of size 8 bytes D 7 12 Constants The following values are used for the constants inside of the protocol gdb and target are resposible to translate these values before and after the call as needed D 7 12 1 Open flags All values are given in hex...

Page 360: ...FBIG 27 ENOSPC 28 ESPIPE 29 EROFS 30 ENAMETOOLONG 91 EUNKNOWN 9999 EUNKNOWN is used as a fallback error value if a host system returns any error value not in the list of supported error numbers D 7 12 4 Lseek flags SEEK_SET 0 SEEK_CUR 1 SEEK_END 2 D 7 12 5 Limits All values are given in decimal representation INT_MIN 2147483648 INT_MAX 2147483647 UINT_MAX 4294967295 LONG_MIN 9223372036854775808 LO...

Page 361: ...scriptor 3 buffer is at target address 0x1234 6 bytes should be read d Fread 3 1234 6 request memory write to target e X1234 6 XXXXXX return 6 bytes read e F6 Example sequence of a read call call fails on the host due to invalid file descriptor EBADF d Fread 3 1234 6 e F 1 9 Example sequence of a read call user presses Ctrl C before syscall on host is called d Fread 3 1234 6 e F 1 4 C d T02 Exampl...

Page 362: ...352 Appendix D gdb Remote Serial Protocol ...

Page 363: ... simple there are forty odd opcodes the bulk of which are the usual vocab ulary of C operands addition subtraction shifts and so on and various sizes of literals and memory reference operations The bytecode interpreter operates strictly on machine level values various sizes of integers and floating point numbers and requires no information about types or symbols thus the interpreter s internal dat...

Page 364: ... upper bits of the values are simply ignored since they do not usually make a difference to the value computed The exceptions to this rule are memory reference instructions refn There are distinct instructions to fetch different word sizes from memory Once on the stack however the values are treated as full size integers They may need to be sign extended the ext instruction exists for this purpose...

Page 365: ...lowing form add 0x02 a b a b Pop the top two stack items a and b as integers push their sum as an integer In this example add is the name of the bytecode and 0x02 is the one byte value used to encode the bytecode in hexidecimal The phrase a b a b shows the stack before and after the bytecode executes Beforehand the stack must contain at least two values a and b since the top of the stack is to the...

Page 366: ...e numbers are signed or not the results are the same div_signed 0x05 a b a b Pop two signed integers from the stack divide the next to top value by the top value and push the quotient If the divisor is zero terminate with an error div_unsigned 0x06 a b a b Pop two unsigned integers from the stack divide the next to top value by the top value and push the quotient If the divisor is zero terminate w...

Page 367: ...an unsigned value from the stack treating it as an n bit twos complement value extend it to full length This means that all bits to the left of bit n 1 where the least significant bit is bit 0 are set to the value of bit n 1 Note that n may be larger than or equal to the width of the stack elements of the bytecode engine in this case the bytecode should have no effect The number of source bits to ...

Page 368: ...n machines where fetching a 16 bit on an unaligned address raises an exception you should fetch the offset one byte at a time goto 0x21 offset Branch unconditionally to offset in other words set the pc register to start offset The offset is stored in the same way as for the if_goto bytecode const8 0x22 n n const16 0x23 n n const32 0x24 n n const64 0x25 n n Push the integer constant n on the stack ...

Page 369: ...hich GDB should collect data The user specifies expressions to evaluate at each trace point These expressions may denote objects in memory in which case those objects contents are recorded as the program runs or computed values in which case the values themselves are recorded GDB transmits the tracepoints and their associated expressions to the GDB agent running on the debugging target The agent a...

Page 370: ... to a value greater than zero If frame does not record any memory at address set size to the distance from address to the start of the saved region with the lowest address higher than address If there is no memory saved from any higher address set size to zero Return NOT_FOUND_TARGET_RESPONSE These two possibilities allow the caller to either retrieve the data or walk the address space to the next...

Page 371: ...uld set size to 0x1000 and return NOT_FOUND_TARGET_RESPONSE since the next saved memory is at 0x7000 0x1000 or 0x8000 adbg_find_memory_in_frame f char 0xf000 buffer size This would set size to zero and return NOT_FOUND_TARGET_RESPONSE This shows how the function tells the caller that no further memory ranges have been saved As another example here is a function which will print out the addresses o...

Page 372: ...this information is not necessary for correctness Why don t you have j or k operators I want to keep the interpreter small and we don t need them We can combine the less_ opcodes with log_not and swap the order of the operands yielding all four asymmetrical comparison operators For example x k y is x j y which is y k x Why do you have log_not Why do you have ext Why do you have zero_ext These are ...

Page 373: ...er always assume the largest offset size or do jump relaxation on the code after I generate it which seems like a big waste of time I can imagine a reasonable expression being longer than 256 bytes I can t imagine one being longer than 64k Thus we need 16 bit offsets This kind of reasoning is so bogus but relaxation is pathetic The other approach would be to generate code right to left Then I d al...

Page 374: ... have a kludge it should be an effective kludge Why does trace16 exist That opcode was added by the customer that contracted Cygnus for the data tracing work I personally think it is unnecessary objects that large will be quite rare so it is okay to use dup const16 size trace in those cases Whatever we decide to do with trace16 we should at least leave opcode 0x30 reserved to remain compatible wit...

Page 375: ...es for you if you distribute copies of the software or if you modify it For example if you distribute copies of such a program whether gratis or for a fee you must give the recipients all the rights that you have You must make sure that they too receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two steps 1 copyright the soft...

Page 376: ...this License c If the modified program normally reads commands interactively when run you must cause it when started running for such interactive use in the most ordinary way to print or dis play an announcement including an appropriate copyright notice and a notice that there is no warranty or else saying that you provide a warranty and that users may redistribute the program under these conditio...

Page 377: ...t signed it However nothing else grants you permission to modify or distribute the Program or its derivative works These actions are prohibited by law if you do not accept this License Therefore by modifying or distributing the Program or any work based on the Program you indicate your acceptance of this License to do so and all its terms and conditions for copying distributing or modifying the Pr...

Page 378: ...or software which is copyrighted by the Free Software Foundation write to the Free Software Foundation we sometimes make exceptions for this Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally NO WARRANTY 12 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE THERE IS NO WARRANTY ...

Page 379: ...and paper mail If the program is interactive make it output a short notice like this when it starts in an interactive mode Gnomovision version 69 Copyright C year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY for details type show w This is free software and you are welcome to redistribute it under certain conditions type show c for details The hypothetical commands show w and show ...

Page 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...

Page 381: ...License principally for works whose purpose is instruction or reference 2 APPLICABILITY AND DEFINITIONS This License applies to any manual or other work that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License The Document below refers to any such manual or work Any member of the public is a licensee and is addressed as you A Modified Versi...

Page 382: ...ng or further copying of the copies you make or distribute However you may accept compensation in exchange for copies If you distribute a large enough number of copies you must also follow the conditions in section 3 You may also lend copies under the same conditions stated above and you may publicly display copies 4 COPYING IN QUANTITY If you publish printed copies of the Document numbering more ...

Page 383: ...rent copy of the Document and likewise the network locations given in the Document for previous versions it was based on These may be placed in the History sec tion You may omit a network location for a work that was published at least four years before the Document itself or if the original publisher of the version it refers to gives permission K In any section entitled Acknowledgements or Dedica...

Page 384: ...f that document 8 AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent docu ments or works in or on a volume of a storage or distribution medium does not as a whole count as a Modified Version of the Document provided no compilation copyright is claimed for the compilation Such a compilation is called an aggregate and this License ...

Page 385: ...ments To use this License in a document you have written include a copy of the License in the document and put the following copyright and license notices just after the title page Copyright C year your name Permission is granted to copy distribute and or modify this document under the terms of the GNU Free Documentation License Version 1 1 or any later version published by the Free Software Found...

Page 386: ...376 Appendix G GNU Free Documentation License ...

Page 387: ...k point table commands break disable refer to Section 26 8 gdb mi Break point table commands break enable refer to Section 26 8 gdb mi Break point table commands break info refer to Section 26 8 gdb mi Breakpoint table commands break insert refer to Section 26 8 gdb mi Breakpoint table commands break list refer to Section 26 8 gdb mi Breakpoint table commands break watch refer to Section 26 8 gdb ...

Page 388: ...Choosing modes nx refer to Section 4 1 2 Choosing modes p refer to Section 4 1 1 Choosing files pid refer to Section 4 1 1 Choosing files q refer to Section 4 1 2 Choosing modes quiet refer to Section 4 1 2 Choosing modes r refer to Section 4 1 1 Choosing files readnow refer to Section 4 1 1 Choosing files s refer to Section 4 1 1 Choosing files se refer to Section 4 1 1 Choosing files silent refe...

Page 389: ... operators and debug subdirectories refer to Section 17 2 Debug ging Information in Separate Files esgdbinit refer to Section 22 3 Command files gdbinit refer to Section 22 3 Command files gnu_debuglink sections refer to Section 17 2 De bugging Information in Separate Files o files reading symbols from refer to Section 17 1 Commands to specify files os68gdbinit refer to Section 22 3 Command files ...

Page 390: ...t refer to Section 27 10 Running the Pro gram breakpoint commands refer to Section 7 1 7 Break point command lists breakpoint commands for gdb mi refer to Section 26 8 gdb mi Breakpoint table commands breakpoint conditions refer to Section 7 1 6 Break conditions breakpoint numbers refer to Section 7 1 Breakpoints watchpoints and catchpoints breakpoint on events refer to Section 7 1 Break points wa...

Page 391: ... to Section 14 3 Type and range checking checksum for gdb remote refer to Section D 1 Overview choosing target byte order refer to Section 18 3 Choosing target byte order clear refer to Section 7 1 4 Deleting breakpoints clear and Objective C refer to Section 14 4 2 1 Method Names in Commands clearing breakpoints watchpoints catchpoints refer to Section 7 1 4 Deleting breakpoints close file i o sy...

Page 392: ...ata Manipulation debug formats and C refer to Section 14 4 1 3 C expressions debug links refer to Section 17 2 Debugging Infor mation in Separate Files debugger crash refer to Section 28 1 Have you found a bug debugging C programs refer to Section 14 4 1 3 C expressions debugging information directory global refer to Sec tion 17 2 Debugging Information in Separate Files debugging information in se...

Page 393: ...2 1 2 Vx Works download dump refer to Section 10 14 Copy between memory and a file dump all data collected at tracepoint refer to Section 12 2 2 tdump dump data to a file refer to Section 10 14 Copy be tween memory and a file dump restore files refer to Section 10 14 Copy be tween memory and a file dynamic linking refer to Section 17 1 Commands to specify files E e edit refer to Section 9 2 Editin...

Page 394: ...r to Section 12 2 1 tfind n finish refer to Section 7 2 Continuing and stepping flinching refer to Section 21 7 Optional warnings and messages float promotion refer to Section 21 6 Configuring the current ABI floating point refer to Section 10 11 Floating point hardware floating point registers refer to Section 10 10 Regis ters floating point MIPS remote refer to Section 20 3 6 MIPS Embedded flush...

Page 395: ...y file i o system call refer to Section D 7 10 9 gettimeofday global debugging information directory refer to Sec tion 17 2 Debugging Information in Separate Files gnu C refer to Section 14 4 1 C and C gnu Emacs refer to Chapter 25 Using gdb under gnu Emacs gnu_debuglink_crc32 refer to Section 17 2 De bugging Information in Separate Files H h help refer to Section 5 3 Getting help H packet refer t...

Page 396: ...rame info breakpoints refer to Section 7 1 1 Setting break points info catch refer to Section 8 4 Information about a frame info classes refer to Chapter 15 Examining the Sym bol Table info display refer to Section 10 6 Automatic display info dll refer to Section 20 1 4 Features for Debug ging MS Windows PE executables info dos refer to Section 20 1 3 Features for Debug ging djgpp Programs info ex...

Page 397: ...r refer to Section 9 5 Source and machine code interaction readline refer to Section 29 2 Readline Interaction internal commands refer to Appendix C Mainte nance Commands internal gdb breakpoints refer to Section 7 1 1 Set ting breakpoints interpreter exec refer to Chapter 23 Command Inter preters interrupt refer to Section 4 2 Quitting gdb interrupting remote programs refer to Section 19 1 Connec...

Page 398: ...ote stub m68k stub c refer to Section 19 5 Implementing a remote stub machine instructions refer to Section 9 5 Source and machine code macro define refer to Chapter 11 C Preprocessor Macros macro definition showing refer to Chapter 11 C Pre processor Macros macro expand refer to Chapter 11 C Preprocessor Macros macro expand once refer to Chapter 11 C Preproces sor Macros macro expansion showing t...

Page 399: ...ns refer to Section 14 4 3 2 Built in functions and procedures Modula 2 checks refer to Section 14 4 3 6 Modula 2 type and range checks Modula 2 constants refer to Section 14 4 3 2 Built in functions and procedures Modula 2 defaults refer to Section 14 4 3 4 Modula 2 defaults Modula 2 operators refer to Section 14 4 3 1 Opera tors Modula 2 deviations from refer to Section 14 4 3 5 Deviations from ...

Page 400: ...3 Debugging Programs That Use Overlays overlays setting breakpoints in refer to Section 13 2 Overlay Commands overload choice refer to Section 27 6 Annotation for gdb Input overloaded functions calling refer to Section 14 4 1 3 C expressions overloaded functions overload resolution refer to Section 14 4 1 7 gdb features for C overloading refer to Section 7 1 8 Breakpoint menus overloading in C ref...

Page 401: ... quit expression refer to Section 4 2 Quitting gdb quotes in commands refer to Section 5 2 Command completion quoting names refer to Chapter 15 Examining the Symbol Table R r run refer to Section 6 2 Starting your program r SingleKey TUI key refer to Section 24 3 TUI Sin gle Key Mode R packet refer to Section D 2 Packets r packet refer to Section D 2 Packets raise exceptions refer to Section 7 1 3...

Page 402: ...9 3 Searching source files Right refer to Section 24 2 TUI Key Bindings run refer to Section 6 2 Starting your program running refer to Section 6 2 Starting your program running and debugging Sparclet programs refer to Section 20 3 11 4 Running and debugging running VxWorks tasks refer to Section 20 2 1 3 Running tasks running on Sparclet refer to Section 20 3 11 Tsqware Sparclet rwatch refer to S...

Page 403: ...ugmemory refer to Section 20 1 4 Features for Debugging MS Windows PE executables set demangle style refer to Section 10 7 Print set tings set disassembly flavor refer to Section 9 5 Source and machine code set editing refer to Section 21 2 Command editing set endian auto refer to Section 18 3 Choosing target byte order set endian big refer to Section 18 3 Choosing target byte order set endian lit...

Page 404: ... mode refer to Section 24 5 TUI config uration variables set variable refer to Section 16 1 Assignment to vari ables set verbose refer to Section 21 7 Optional warnings and messages set width refer to Section 21 4 Screen size set write refer to Section 16 6 Patching programs set_debug_traps refer to Section 19 5 1 What the stub can do for you setting variables refer to Section 16 1 Assignment to v...

Page 405: ... Print set tings show print max symbolic offset refer to Section 10 7 Print settings show print object refer to Section 10 7 Print settings show print pretty refer to Section 10 7 Print settings show print sevenbit strings refer to Section 10 7 Print settings show print static members refer to Section 10 7 Print settings show print symbol filename refer to Section 10 7 Print settings show print un...

Page 406: ...Continuing and stepping stepping refer to Section 7 2 Continuing and step ping stepping into functions with no line info refer to Sec tion 7 2 Continuing and stepping stop a running trace experiment refer to Section 12 1 6 Starting and Stopping Trace Experiment stop reply packets refer to Section D 3 Stop Reply Packets stop a pseudo command refer to Section 22 2 User defined command hooks stopped ...

Page 407: ...5 M68k target rombug refer to Section 20 3 5 M68k target sds refer to Section 20 3 8 PowerPC target sh3 with H8 300 refer to Section 20 3 2 Hi tachi H8 300 target sh3 with SH refer to Section 20 3 10 Hitachi SH target sh3e with H8 300 refer to Section 20 3 2 Hi tachi H8 300 target sh3e with SH refer to Section 20 3 10 Hitachi SH target sim refer to Section 18 2 Commands for man aging targets targe...

Page 408: ... port target remote refer to Section 19 1 Connecting to a remote target undisplay refer to Section 10 6 Automatic display unknown address locating refer to Section 10 4 Out put formats unlink file i o system call refer to Section D 7 10 7 unlink unmap an overlay refer to Section 13 2 Overlay Commands unmapped overlays refer to Section 13 1 How Over lays Work unset environment refer to Section 6 4 ...

Page 409: ... gdb with Different Languages write file i o system call refer to Section D 7 10 4 write writing into corefiles refer to Section 16 6 Patching programs writing into executables refer to Section 16 6 Patch ing programs wrong values refer to Section 10 2 Program vari ables X x examine memory refer to Section 10 5 Examin ing memory X packet refer to Section D 2 Packets x examine and info line refer t...

Page 410: ......

Reviews: