Your SlideShare is downloading. ×
Gdb cheat sheet
Gdb cheat sheet
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Gdb cheat sheet

799

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
799
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. GDB cheatsheet - page 1 Running <where> next# gdb <program> [core dump] function_name Go to next instruction (source line) but Start GDB (with optional core dump). Break/watch the named function. donʻt dive into functions.# gdb --args <program> <args…> line_number finish Start GDB and pass arguments Break/watch the line number in the cur- Continue until the current function re- rent source file. turns.# gdb --pid <pid> Start GDB and attach to process. file:line_number continue Break/watch the line number in the Continue normal execution.set args <args...> named source file. Set arguments to pass to program to Variables and memory be debugged. Conditions print/format <what> break/watch <where> if <condition> Print content of variable/memory locati-run Break/watch at the given location if the on/register. Run the program to be debugged. condition is met. display/format <what>kill Conditions may be almost any C ex- Like „print“, but print the information Kill the running program. pression that evaluate to true or false. after each stepping instruction. Breakpoints condition <breakpoint#> <condition> undisplay <display#>break <where> Set/change the condition of an existing Remove the „display“ with the given Set a new breakpoint. break- or watchpoint. number.delete <breakpoint#> Examining the stack enable display <display#> Remove a breakpoint. backtrace disable display <display#>clear where En- or disable the „display“ with the gi- Delete all breakpoints. Show call stack. ven number.enable <breakpoint#> backtrace full x/nfu <address> Enable a disabled breakpoint. where full Print memory. Show call stack, also print the local va- n: How many units to print (default 1).disable <breakpoint#> f: Format character (like „print“). riables in each frame. Disable a breakpoint. u: Unit. frame <frame#> Watchpoints Select the stack frame to operate on. Unit is one of:watch <where> b: Byte, Set a new watchpoint. Stepping h: Half-word (two bytes) stepdelete/enable/disable <watchpoint#> w: Word (four bytes) Go to next instruction (source line), di- Like breakpoints. g: Giant word (eight bytes)). ving into function. © 2007 Marc Haisenko <marc@darkdust.net>
  • 2. GDB cheatsheet - page 2 Format Manipulating the program Informationsa Pointer. set var <variable_name>=<value> disassemblec Read as integer, print as character. Change the content of a variable to the disassemble <where>d Integer, signed decimal. given value. Disassemble the current function orf Floating point number. given location. return <expression>o Integer, print as octal. Force the current function to return im- info argss Try to treat as C string. mediately, passing the given value. Print the arguments to the function oft Integer, print as binary (t = „two“). the current stack frame.u Integer, unsigned decimal. Sourcesx Integer, print as hexadecimal. directory <directory> info breakpoints Print informations about the break- and <what> Add directory to the list of directories that is searched for sources. watchpoints.expression Almost any C expression, including list info display function calls (must be prefixed with a list <filename>:<function> Print informations about the „displays“. cast to tell GDB the return value type). list <filename>:<line_number> info localsfile_name::variable_name list <first>,<last> Print the local variables in the currently Content of the variable defined in the Shows the current or given source con- selected stack frame. named file (static variables). text. The filename may be omitted. If last is omitted the context starting at info sharedlibraryfunction::variable_name start is printed instead of centered a- List loaded shared libraries. Content of the variable defined in the round it. info signals named function (if on the stack). List all signals and how they are cur- set listsize <count>{type}address Set how many lines to show in „list“. rently handled. Content at address, interpreted as info threads being of the C type type. Signals List all threads.$register handle <signal> <options> Set how to handle signles. Options are: show directories Content of named register. Interesting Print all directories in which GDB sear- registers are $esp (stack pointer), $ebp (no)print: (Donʻt) print a message when ches for source files. (frame pointer) and $eip (instruction signals occurs. pointer). show listsize (no)stop: (Donʻt) stop the program Print how many are shown in the „list“ Threads when signals occurs. command.thread <thread#> (no)pass: (Donʻt) pass the signal to the whatis variable_name Chose thread to operate on. program. Print type of named variable. © 2007 Marc Haisenko <marc@darkdust.net>

×