HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

gdb — The GNU Debugger. More information: <https://sourceware.org/gdb/current/onlinedocs/gdb#Invocation>.

Submitted by: @import:tldr-pages··
0
Viewed 0 times
thecommandgdbcliinformationgnudebuggermore

Problem

How to use the gdb command: The GNU Debugger. More information: <https://sourceware.org/gdb/current/onlinedocs/gdb#Invocation>.

Solution

gdb — The GNU Debugger. More information: <https://sourceware.org/gdb/current/onlinedocs/gdb#Invocation>.

Debug an executable:
gdb {{path/to/executable}}


Attach a process to gdb:
gdb {{[-p|--pid]}} {{procID}}


Debug with a core file:
gdb {{[-c|--core]}} {{path/to/core}} {{path/to/executable}}


Execute given GDB commands upon start:
gdb {{[-ex|--eval-command]}} "{{commands}}" {{path/to/executable}}


Start gdb and pass arguments to the executable:
gdb --args {{path/to/executable}} {{argument1 argument2 ...}}


Skip debuginfod and pagination prompts and then print the backtrace:
gdb {{[-c|--core]}} {{path/to/core}} {{path/to/executable}} -iex 'set debuginfod enabled on' -iex 'set pagination off' -ex bt

Code Snippets

Debug an executable

gdb {{path/to/executable}}

Attach a process to `gdb`

gdb {{[-p|--pid]}} {{procID}}

Debug with a core file

gdb {{[-c|--core]}} {{path/to/core}} {{path/to/executable}}

Execute given GDB commands upon start

gdb {{[-ex|--eval-command]}} "{{commands}}" {{path/to/executable}}

Start `gdb` and pass arguments to the executable

gdb --args {{path/to/executable}} {{argument1 argument2 ...}}

Context

tldr-pages: common/gdb

Revisions (0)

No revisions yet.