SlideShare ist ein Scribd-Unternehmen logo
1 von 2
Downloaden Sie, um offline zu lesen
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>

Weitere ähnliche Inhalte

Was ist angesagt?

BADI IMPLEMENTATION.pdf
BADI IMPLEMENTATION.pdfBADI IMPLEMENTATION.pdf
BADI IMPLEMENTATION.pdfssuser08365f
 
Error Management: Future vs ZIO
Error Management: Future vs ZIOError Management: Future vs ZIO
Error Management: Future vs ZIOJohn De Goes
 
python practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdfpython practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdfrajatxyz
 
Jetpack Compose - Android’s modern toolkit for building native UI
Jetpack Compose - Android’s modern toolkit for building native UIJetpack Compose - Android’s modern toolkit for building native UI
Jetpack Compose - Android’s modern toolkit for building native UIGilang Ramadhan
 
Container based android
Container based androidContainer based android
Container based androidLihan Chen
 
Utilizing kotlin flows in an android application
Utilizing kotlin flows in an android applicationUtilizing kotlin flows in an android application
Utilizing kotlin flows in an android applicationSeven Peaks Speaks
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersJiaxuan Lin
 
Develop a connector on any apps using Odoo-connector
Develop a connector on any apps using Odoo-connectorDevelop a connector on any apps using Odoo-connector
Develop a connector on any apps using Odoo-connectorodoohub
 
Functional Programming.pptx
Functional Programming.pptxFunctional Programming.pptx
Functional Programming.pptxKarthickT28
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of SignalsCoding Academy
 
Flutter session 01
Flutter session 01Flutter session 01
Flutter session 01DSC IEM
 
Jetpack Compose beginner.pdf
Jetpack Compose beginner.pdfJetpack Compose beginner.pdf
Jetpack Compose beginner.pdfAayushmaAgrawal
 
LinkedList vs Arraylist- an in depth look at java.util.LinkedList
LinkedList vs Arraylist- an in depth look at java.util.LinkedListLinkedList vs Arraylist- an in depth look at java.util.LinkedList
LinkedList vs Arraylist- an in depth look at java.util.LinkedListMarcus Biel
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java DevelopersYakov Fain
 
Ab1011 module pool programming
Ab1011   module pool programmingAb1011   module pool programming
Ab1011 module pool programmingSatheesh Kanna
 
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...Compose Camp - Jetpack Compose for Android Developers Introduction Session De...
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...JassGroup TICS
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKJosé Paumard
 
GPDB Meetup GPORCA OSS 101
GPDB Meetup GPORCA OSS 101GPDB Meetup GPORCA OSS 101
GPDB Meetup GPORCA OSS 101Xin Zhang
 

Was ist angesagt? (20)

BADI IMPLEMENTATION.pdf
BADI IMPLEMENTATION.pdfBADI IMPLEMENTATION.pdf
BADI IMPLEMENTATION.pdf
 
Error Management: Future vs ZIO
Error Management: Future vs ZIOError Management: Future vs ZIO
Error Management: Future vs ZIO
 
python practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdfpython practicals-solution-2019-20-class-xii.pdf
python practicals-solution-2019-20-class-xii.pdf
 
Jetpack Compose - Android’s modern toolkit for building native UI
Jetpack Compose - Android’s modern toolkit for building native UIJetpack Compose - Android’s modern toolkit for building native UI
Jetpack Compose - Android’s modern toolkit for building native UI
 
Container based android
Container based androidContainer based android
Container based android
 
Utilizing kotlin flows in an android application
Utilizing kotlin flows in an android applicationUtilizing kotlin flows in an android application
Utilizing kotlin flows in an android application
 
Provider vs BLoC vs Redux
Provider vs BLoC vs ReduxProvider vs BLoC vs Redux
Provider vs BLoC vs Redux
 
Developer Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for BeginnersDeveloper Student Clubs NUK - Flutter for Beginners
Developer Student Clubs NUK - Flutter for Beginners
 
Develop a connector on any apps using Odoo-connector
Develop a connector on any apps using Odoo-connectorDevelop a connector on any apps using Odoo-connector
Develop a connector on any apps using Odoo-connector
 
Functional Programming.pptx
Functional Programming.pptxFunctional Programming.pptx
Functional Programming.pptx
 
Angular 16 – the rise of Signals
Angular 16 – the rise of SignalsAngular 16 – the rise of Signals
Angular 16 – the rise of Signals
 
Flutter session 01
Flutter session 01Flutter session 01
Flutter session 01
 
Jetpack Compose beginner.pdf
Jetpack Compose beginner.pdfJetpack Compose beginner.pdf
Jetpack Compose beginner.pdf
 
LinkedList vs Arraylist- an in depth look at java.util.LinkedList
LinkedList vs Arraylist- an in depth look at java.util.LinkedListLinkedList vs Arraylist- an in depth look at java.util.LinkedList
LinkedList vs Arraylist- an in depth look at java.util.LinkedList
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java Developers
 
Ab1011 module pool programming
Ab1011   module pool programmingAb1011   module pool programming
Ab1011 module pool programming
 
Python/Django Training
Python/Django TrainingPython/Django Training
Python/Django Training
 
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...Compose Camp - Jetpack Compose for Android Developers Introduction Session De...
Compose Camp - Jetpack Compose for Android Developers Introduction Session De...
 
Deep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UKDeep Dive Java 17 Devoxx UK
Deep Dive Java 17 Devoxx UK
 
GPDB Meetup GPORCA OSS 101
GPDB Meetup GPORCA OSS 101GPDB Meetup GPORCA OSS 101
GPDB Meetup GPORCA OSS 101
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von Piyush Mittal

Mehr von 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>