17.6. Group Listing of GDB Commands

 < Day Day Up > 

This section summarizes the GDB commands by task. Esoteric commands, such as those used by GDB's maintainers, or to cross-debug remote systems connected via serial port or a network, have been omitted.

17.6.1. Aliases for Other Commands

Alias

Short for...

Alias

Short for...

Alias

Short for...

bt

backtrace

f

frame

p

print

c

continue

fo

forward-search

po

print-object

cont

continue

gcore

generate-core-file

r

run

d

delete

h

help

s

step

dir

directory

i

info

share

sharedlibrary

dis

disable

l

list

si

stepi

do

down

n

next

u

until

e

edit

ni

nexti

where

backtrace


17.6.2. Breakpoints

awatch

Set an expression watchpoint.

break

Set a breakpoint at a line or function.

catch

Set a catchpoint to catch an event.

clear

Clear a given breakpoint.

commands

Specify commands to run when a breakpoint is reached.

condition

Supply a condition to a particular breakpoint.

delete

Delete one more breakpoints or auto-display expressions.

disable

Disable one or more breakpoints.

enable

Enable one or more breakpoints.

hbreak

Set a hardware assisted breakpoint.

ignore

Set the ignore-count of a particular breakpoint.

rbreak

Set a breakpoint for all functions matching a regular expression.

rwatch

Set a read watchpoint for an expression.

tbreak

Set a temporary breakpoint.

tcatch

Set a temporary catchpoint.

thbreak

Set a temporary hardware assisted breakpoint.

watch

Set an expression watchpoint.


17.6.3. Examining Data

call

Call a function in the program.

delete display

Cancel one or more expressions that have been set to display when the program stops.

delete mem

Delete a memory region.

disable display

Disable one or more expressions that have been set to display when the program stops.

disable mem

Disable a memory region.

disassemble

Disassemble a section of memory.

display

Print the value of an expression each time the program stops.

enable display

Enable one or more expressions that have been set to display when the program stops.

enable mem

Enable a memory region.

inspect

Same as print.

mem

Define attributes for a memory region.

output

Similar to print, but doesn't save the value in history and doesn't print a newline. For scripting.

print

Print the value of an expression.

print-object

Cause an Objective C object to print information about itself.

printf

Print values like the printf command.

ptype

Print the definition of a given type.

set

Evaluate an expression and save the result in a program variable.

set variable

Same as set, avoids conflict with GDB variables.

undisplay

Cancel one or more expressions that have been set to display when the program stops.

whatis

Print the data type of an expression.

x

Examine memory: x/fmt address. See the entry for x in the later section "Alphabetical Summary of GDB Commands."


17.6.4. Controlling and Examining Files


add-symbol-file

Add symbols from a dynamically loaded file to GDB's symbol table.


add-symbol-file-from-memory

Load the symbols from a dynamically loaded object file in the debuggee's memory.


cd

Set the current directory for GDB and the debuggee.


core-file

Specify a file to use as the core dump for memory and register contents.


directory

Add a directory to the beginning of the source file search path.


edit

Edit a file or function.


exec-file

Specify a file to use as the executable.


file

Specify the filename of the program to be debugged.


forward-search

Search forward in the current source file for a regular expression, starting at the last line listed.


generate-core-file

Create a core file from the current state of the debuggee.


list

List a function or line.


nosharedlibrary

Unload all shared object library symbols.


path

Add one or more directories to the object file search path.


pwd

Print the current directory.


reverse-search

Search backward in the current source file for a regular expression, starting at the last line listed.


search

Same as forward-search.


section

Change the base address of a particular section in the exec file.


sharedlibrary

Load shared object library symbols for files matching a regular expression.


symbol-file

Load symbol table information from a specified executable file.

17.6.5. Running a Program

advance

Continue the program up to the given location.

attach

Attach to a process or file outside of GDB.

continue

Continue the program being debugged.

detach

Detach a previously attached process or file.

finish

Execute until selected stack frame returns.

handle

Specify how to handle a signal.

interrupt

Interrupt the execution of the debugged program.

jump

Continue program being debugged at specified line or address.

kill

Kill the program being debugged.

next

Execute the program's next statement.

nexti

Execute the program's next instruction.

run

Start the debugged program.

signal

Continue the program, giving it a specified signal.

start

Run the debugged program until the beginning of the main procedure. Useful for C++ where constructors run before main( ).

step

Step the program until it reaches a different source line. Descends into called functions.

stepi

Step exactly one instruction.

thread

Switch between threads.

tHRead apply

Apply a command to a list of threads.

tHRead apply all

Apply a command to all threads.

tty

Set the terminal for future runs of the debuggee.

unset environment

Remove a variable from the debuggee's environment.

until

Execute until the program reaches a source line greater than the current one.


17.6.6. Examining the Stack

backtrace

Print a backtrace of all stack frames.

down

Select and print the stack frame called by the current one.

frame

Select and print a stack frame.

return

Make selected stack frame return to its caller.

select-frame

Select a stack frame without printing anything.

up

Select and print the stack frame that called the current one.


17.6.7. Status Inquiries

info

General command for showing information about the debuggee.

macro

Prefix for commands dealing with C preprocessor macros.

show

General command for showing information about the debugger.


17.6.8. Support Facilities

apropos

Search for commands matching a regular expression.

complete

List the command completions for the rest of the line.

define

Define a new command.

document

Document a user-defined command.

dont-repeat

Don't repeat this command. For use in user-defined commands.

down-silently

Same as the down command, but doesn't print messages.

echo

Print a constant string.

else

Provide a list of alternative commands for use with if.

end

End a list of commands or actions.

help

Print list of commands.

if

Execute nested commands once if the conditional expression is nonzero.

make

Run the make program using the rest of the line as arguments.

quit

Exit GDB.

shell

Execute the rest of the line as a shell command.

source

Read commands from a named file.

up-silently

Same as the up command, but doesn't print messages.

while

Execute nested commands while the conditional expression is nonzero.


17.6.9. Text User Interface Commands

focus

Change which window receives the keyboard focus.

layout

Change the layout of the windows in use.

refresh

Clear and redraw the screen.

tui reg

Change which registers are shown in the register window.

update

Update the source window.

winheight

Change the height of a particular window.


17.6.10. Frequently Used Commands

GDB offers a bewilderingly large number of commands, but most users can get by with just a small handful. Table 17-1 lists the ones that you are likely to use most often.

Table 17-1. The top dozen GDB commands

Command

Purpose

Examples

backtrace

Show call trace

ba

break

Set breakpoint at routine entry or at line number

b main

  

b parser.c:723

continue

Continue from breakpoint

cont

delete

Remove breakpoint

d 3

finish

Step until end of routine

fin

info breakpoints

List current breakpoints

i br

next

Step to next statement and over routine calls

ne

print

Print expression

print 1.0/3.0

run

(Re)run program, optionally with arguments

ru

  

ru -u -o foo < data

step

Step to next statement and into routines

s

x

Examine memory

x/s *environ

until

Continue execution until reaching a source line

until

  

until 2367


     < Day Day Up > 


    Unix in a Nutshell
    Unix in a Nutshell, Fourth Edition
    ISBN: 0596100299
    EAN: 2147483647
    Year: 2005
    Pages: 201

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net