SlideShare uma empresa Scribd logo
1 de 2
Baixar para ler offline
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)
                                                step
delete/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>
GDB cheatsheet - page 2
                    Format                                  Manipulating the program                                       Informations
a
         Pointer.                                 set var <variable_name>=<value>                       disassemble
c
         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 or
f
         Floating point number.                                                                                  given location.
                                                    return <expression>
o
         Integer, print as octal.                          Force the current function to return im-     info args
s
         Try to treat as C string.                         mediately, passing the given value.                   Print the arguments to the function of
t
         Integer, print as binary (t = „two“).                                                                   the current stack frame.
u
         Integer, unsigned decimal.                                   Sources
x
         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 locals
file_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 sharedlibrary
function::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>

Mais conteúdo relacionado

Mais procurados

Product Pre Release Security Validation Checklist v1.0
Product Pre Release Security Validation Checklist v1.0Product Pre Release Security Validation Checklist v1.0
Product Pre Release Security Validation Checklist v1.0Mike Horton
 
Thread model of java
Thread model of javaThread model of java
Thread model of javamyrajendra
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket ProgrammingVipin Yadav
 
L14 exception handling
L14 exception handlingL14 exception handling
L14 exception handlingteach4uin
 
Practical Malware Analysis Ch12
Practical Malware Analysis Ch12Practical Malware Analysis Ch12
Practical Malware Analysis Ch12Sam Bowne
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingRana Khalil
 
Exception Handling In Java
Exception Handling In JavaException Handling In Java
Exception Handling In Javaparag
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in javaARAFAT ISLAM
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handlingNahian Ahmed
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handlingkamal kotecha
 
Tiered Compilation in Hotspot JVM
Tiered Compilation in Hotspot JVMTiered Compilation in Hotspot JVM
Tiered Compilation in Hotspot JVMIgor Veresov
 
Serialization/deserialization
Serialization/deserializationSerialization/deserialization
Serialization/deserializationYoung Alista
 
Blockchain consensus algorithms
Blockchain consensus algorithmsBlockchain consensus algorithms
Blockchain consensus algorithmsAnurag Dashputre
 
Java SE 8 lambdaで変わる プログラミングスタイル
Java SE 8 lambdaで変わる プログラミングスタイルJava SE 8 lambdaで変わる プログラミングスタイル
Java SE 8 lambdaで変わる プログラミングスタイルなおき きしだ
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCFAKHRUN NISHA
 

Mais procurados (20)

Product Pre Release Security Validation Checklist v1.0
Product Pre Release Security Validation Checklist v1.0Product Pre Release Security Validation Checklist v1.0
Product Pre Release Security Validation Checklist v1.0
 
Thread model of java
Thread model of javaThread model of java
Thread model of java
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
 
L14 exception handling
L14 exception handlingL14 exception handling
L14 exception handling
 
Practical Malware Analysis Ch12
Practical Malware Analysis Ch12Practical Malware Analysis Ch12
Practical Malware Analysis Ch12
 
Introduction to Web Application Penetration Testing
Introduction to Web Application Penetration TestingIntroduction to Web Application Penetration Testing
Introduction to Web Application Penetration Testing
 
Exception Handling In Java
Exception Handling In JavaException Handling In Java
Exception Handling In Java
 
Exception handling in java
Exception handling in javaException handling in java
Exception handling in java
 
Presentation on-exception-handling
Presentation on-exception-handlingPresentation on-exception-handling
Presentation on-exception-handling
 
Java Exception handling
Java Exception handlingJava Exception handling
Java Exception handling
 
Tiered Compilation in Hotspot JVM
Tiered Compilation in Hotspot JVMTiered Compilation in Hotspot JVM
Tiered Compilation in Hotspot JVM
 
Serialization/deserialization
Serialization/deserializationSerialization/deserialization
Serialization/deserialization
 
Debugging
DebuggingDebugging
Debugging
 
Ethereum
EthereumEthereum
Ethereum
 
Java Threads
Java ThreadsJava Threads
Java Threads
 
Blockchain consensus algorithms
Blockchain consensus algorithmsBlockchain consensus algorithms
Blockchain consensus algorithms
 
Java SE 8 lambdaで変わる プログラミングスタイル
Java SE 8 lambdaで変わる プログラミングスタイルJava SE 8 lambdaで変わる プログラミングスタイル
Java SE 8 lambdaで変わる プログラミングスタイル
 
JDK,JRE,JVM
JDK,JRE,JVMJDK,JRE,JVM
JDK,JRE,JVM
 
Java/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBCJava/Servlet/JSP/JDBC
Java/Servlet/JSP/JDBC
 
Ophcrack
OphcrackOphcrack
Ophcrack
 

Semelhante a Gdb cheat sheet

Debugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbDebugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbSenthilKumar Selvaraj
 
Gdb tutorial-handout
Gdb tutorial-handoutGdb tutorial-handout
Gdb tutorial-handoutSuraj Kumar
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDBLinaro
 
Android Bootstrap
Android BootstrapAndroid Bootstrap
Android Bootstrapdonnfelker
 
淺入淺出 GDB
淺入淺出 GDB淺入淺出 GDB
淺入淺出 GDBJim Chang
 
Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph Ceph Community
 
Background Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbBackground Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbJuan Maiz
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdbOwen Hsu
 
Rapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and RailsRapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and Railselliando dias
 
Uwaga na buga! GDB w służbie programisty. Barcamp Semihalf S09:E01
Uwaga na buga! GDB w służbie programisty.  Barcamp Semihalf S09:E01Uwaga na buga! GDB w służbie programisty.  Barcamp Semihalf S09:E01
Uwaga na buga! GDB w służbie programisty. Barcamp Semihalf S09:E01Semihalf
 

Semelhante a Gdb cheat sheet (20)

Debugging Modern C++ Application with Gdb
Debugging Modern C++ Application with GdbDebugging Modern C++ Application with Gdb
Debugging Modern C++ Application with Gdb
 
Gccgdb
GccgdbGccgdb
Gccgdb
 
A short guide to git's interactive rebase
A short guide to git's interactive rebaseA short guide to git's interactive rebase
A short guide to git's interactive rebase
 
Gdb tutorial-handout
Gdb tutorial-handoutGdb tutorial-handout
Gdb tutorial-handout
 
Q2.12: Debugging with GDB
Q2.12: Debugging with GDBQ2.12: Debugging with GDB
Q2.12: Debugging with GDB
 
Android Bootstrap
Android BootstrapAndroid Bootstrap
Android Bootstrap
 
淺入淺出 GDB
淺入淺出 GDB淺入淺出 GDB
淺入淺出 GDB
 
Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph Ceph Day Melbourne - Troubleshooting Ceph
Ceph Day Melbourne - Troubleshooting Ceph
 
Wavedigitech gdb
Wavedigitech gdbWavedigitech gdb
Wavedigitech gdb
 
Background Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbBackground Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRb
 
Introduction to gdb
Introduction to gdbIntroduction to gdb
Introduction to gdb
 
issue35 zh-CN
issue35 zh-CNissue35 zh-CN
issue35 zh-CN
 
Rapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and RailsRapid Development with Ruby/JRuby and Rails
Rapid Development with Ruby/JRuby and Rails
 
GIT Basics
GIT BasicsGIT Basics
GIT Basics
 
Uwaga na buga! GDB w służbie programisty. Barcamp Semihalf S09:E01
Uwaga na buga! GDB w służbie programisty.  Barcamp Semihalf S09:E01Uwaga na buga! GDB w służbie programisty.  Barcamp Semihalf S09:E01
Uwaga na buga! GDB w służbie programisty. Barcamp Semihalf S09:E01
 
Perl Intro 4 Debugger
Perl Intro 4 DebuggerPerl Intro 4 Debugger
Perl Intro 4 Debugger
 
Sdl Basic
Sdl BasicSdl Basic
Sdl Basic
 
Confluence
ConfluenceConfluence
Confluence
 
05-Debug.pdf
05-Debug.pdf05-Debug.pdf
05-Debug.pdf
 
A Life of breakpoint
A Life of breakpointA Life of breakpoint
A Life of breakpoint
 

Mais de Piyush Mittal

Mais de Piyush Mittal (20)

Power mock
Power mockPower mock
Power mock
 
Design pattern tutorial
Design pattern tutorialDesign pattern tutorial
Design pattern tutorial
 
Reflection
ReflectionReflection
Reflection
 
Gpu archi
Gpu archiGpu archi
Gpu archi
 
Cuda Architecture
Cuda ArchitectureCuda Architecture
Cuda Architecture
 
Intel open mp
Intel open mpIntel open mp
Intel open mp
 
Intro to parallel computing
Intro to parallel computingIntro to parallel computing
Intro to parallel computing
 
Cuda toolkit reference manual
Cuda toolkit reference manualCuda toolkit reference manual
Cuda toolkit reference manual
 
Matrix multiplication using CUDA
Matrix multiplication using CUDAMatrix multiplication using CUDA
Matrix multiplication using CUDA
 
Channel coding
Channel codingChannel coding
Channel coding
 
Basics of Coding Theory
Basics of Coding TheoryBasics of Coding Theory
Basics of Coding Theory
 
Java cheat sheet
Java cheat sheetJava cheat sheet
Java cheat sheet
 
Google app engine cheat sheet
Google app engine cheat sheetGoogle app engine cheat sheet
Google app engine cheat sheet
 
Git cheat sheet
Git cheat sheetGit cheat sheet
Git cheat sheet
 
Vi cheat sheet
Vi cheat sheetVi cheat sheet
Vi cheat sheet
 
Css cheat sheet
Css cheat sheetCss cheat sheet
Css cheat sheet
 
Cpp cheat sheet
Cpp cheat sheetCpp cheat sheet
Cpp cheat sheet
 
Ubuntu cheat sheet
Ubuntu cheat sheetUbuntu cheat sheet
Ubuntu cheat sheet
 
Php cheat sheet
Php cheat sheetPhp cheat sheet
Php cheat sheet
 
oracle 9i cheat sheet
oracle 9i cheat sheetoracle 9i cheat sheet
oracle 9i cheat sheet
 

Gdb cheat sheet

  • 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) step delete/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 Informations a Pointer. set var <variable_name>=<value> disassemble c 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 or f Floating point number. given location. return <expression> o Integer, print as octal. Force the current function to return im- info args s Try to treat as C string. mediately, passing the given value. Print the arguments to the function of t Integer, print as binary (t = „two“). the current stack frame. u Integer, unsigned decimal. Sources x 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 locals file_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 sharedlibrary function::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>