0% found this document useful (0 votes)
8 views

gdb_commands_reference_final

This document is a reference guide for GDB commands, providing a list of commands along with their descriptions and examples. It includes commands for running programs, setting and managing breakpoints, stepping through code, and printing variable values. The guide also offers commands for navigating the stack and accessing help within GDB.

Uploaded by

umpcmp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

gdb_commands_reference_final

This document is a reference guide for GDB commands, providing a list of commands along with their descriptions and examples. It includes commands for running programs, setting and managing breakpoints, stepping through code, and printing variable values. The guide also offers commands for navigating the stack and accessing help within GDB.

Uploaded by

umpcmp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

GDB Commands Reference

Command Description Example

r[un] Run to next breakpoint or to end (gdb) run

b[reak] <name> Set a breakpoint at function <name> (gdb) break main

b <class>::<name> Set a breakpoint in <class> (gdb) break MyClass::func

b <class>::<tab> List all members in <class> (gdb) break MyClass::<tab>

i[nfo] b List breakpoints (gdb) info breakpoints

dis[able] <n> Disable breakpoint <n> (gdb) disable 1

en[able] <n> Enable breakpoint <n> (gdb) enable 1

d[elete] <n> Delete breakpoint <n> (gdb) delete 1

d[elete] Delete all breakpoints (gdb) delete

cond[ition] <n> <expr> Stop at breakpoint <n> only if <expr> is true (gdb) condition 1 x > 5

cond <n> Make breakpoint <n> unconditional (gdb) condition 1

s[tep] Single-step, descending into functions (gdb) step

n[ext] Single-step without descending into functions (gdb) next

fin[ish] Finish current function, loop, etc. (gdb) finish

c[ontinue] Continue to next breakpoint or end (gdb) continue

u[ntil] <line> Run until it reaches the given line (gdb) until 42

jump <location> Set execution to a new location (gdb) jump main

p[rint] <name> Print value of variable <name> (gdb) print x

p *<name> Print what is pointed to by <name> (gdb) print *ptr

p/x <name> Print value of <name> in hex format (gdb) print/x x

p <name> @ <n> Print <n> values starting at <name> (gdb) print arr@5

p <chars><tab> List all variables starting with <chars> (gdb) print var<tab>

up Go up one context level on stack (gdb) up

do[wn] Go down one level (only possible after up) (gdb) down

l[ist] Show lines of code surrounding the current point (gdb) list

h[elp] Get help on gdb commands (gdb) help

h[elp] <cmd> Get help on a specific gdb command (gdb) help run

q[uit] Exit gdb (gdb) quit

Page 1

You might also like