LinuxDevCenter.com
oreilly.comSafari Books Online.Conferences.

advertisement


Linux in a Nutshell

This directory of Linux commands is from Linux in a Nutshell, 5th Edition.

Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.

Buy it now, or read it online on Safari Bookshelf.



gdb

gdb [options] [program [core|pid] ]

GDB (GNU DeBugger) allows you to step through the execution of a program in order to find the point at which it breaks. It fully supports C and C++, and provides partial support for FORTRAN, Java, Chill, assembly, and Modula-2. The program to be debugged is normally specified on the command line; you can also specify a core or, if you want to investigate a running program, a process ID.

Options

-b bps

Set line speed of serial device used by GDB to bps.

-batch

Exit after executing all the commands specified in .gdbinit and -x files. Print no startup messages.

-c file, -core=file

Consult file for information provided by a core dump.

-cd=directory

Use directory as gdb's working directory.

-d directory, -directory=directory

Include directory in path that is searched for source files.

-e file, -exec=file

Use file as an executable to be read in conjunction with source code. May be used in conjunction with -s to read the symbol table from the executable.

-f, -fullname

Show full filename and line number for each stack frame.

-h, -help

Print help message, then exit.

-n, -nx

Ignore .gdbinit file.

-q, -quiet

Suppress introductory and copyright messages.

-s file, -symbols=file

Consult file for symbol table. With -e, also uses file as the executable.

-tty=device

Set standard in and standard out to device.

-write

Allow gdb to write into executables and core files.

-x file, -command=file

Read gdb commands from file.

Common commands

These are just some of the more common gdb commands; there are too many to list them all.

bt

Print the current location within the program and a stack trace showing how the current location was reached. (where does the same thing.)

break

Set a breakpoint in the program.

cd

Change the current working directory.

clear

Delete the breakpoint where you just stopped.

commands

List commands to be executed when a breakpoint is hit.

c

Continue execution from a breakpoint.

delete

Delete a breakpoint or a watchpoint; also used in conjunction with other commands.

display

Cause variables or expressions to be displayed when program stops.

down

Move down one stack frame to make another function the current one.

frame

Select a frame for the next continue command.

info

Show a variety of information about the program. For instance, info breakpoints shows all outstanding breakpoints and watchpoints.

jump

Start execution at another point in the source file.

kill

Abort the process running under gdb's control.

list

List the contents of the source file corresponding to the program being executed.

next

Execute the next source line, executing a function in its entirety.

print

Print the value of a variable or expression.

ptype

Show the contents of a datatype, such as a structure or C++ class.

pwd

Show the current working directory.

quit

Exit gdb.

reverse-search

Search backward for a regular expression in the source file.

run

Execute the program.

search

Search for a regular expression in the source file.

set variable

Assign a value to a variable.

signal

Send a signal to the running process.

step

Execute the next source line, stepping into a function if necessary.

undisplay

Reverse the effect of the display command; keep expressions from being displayed.

until

Finish the current loop.

up

Move up one stack frame to make another function the current one.

watch

Set a watchpoint (i.e., a data breakpoint) in the program.

whatis

Print the type of a variable or function.


Linux Resources
  • Linux Online
  • The Linux FAQ
  • linux.java.net
  • Linux Kernel Archives
  • Kernel Traffic
  • DistroWatch.com


  • Sponsored by: