From 582b90ddf4ecf5505fa3de9b3ca55ab41cf0f111 Mon Sep 17 00:00:00 2001 From: johannst Date: Tue, 17 Mar 2020 21:17:30 +0100 Subject: updated gdb --- src/gdb.md | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/gdb.md b/src/gdb.md index c11a85d..7a43ca1 100644 --- a/src/gdb.md +++ b/src/gdb.md @@ -72,6 +72,7 @@ # User commands (macros) +Gdb allows to create & document user commands as follows: ```markdown define # cmds @@ -80,29 +81,34 @@ document # docu end +``` - help user-defined List user defined commands. - help List documentation for command . +To get all user commands or documentations one can use: +```markdown + help user-defined + help ``` # Hooks -Gdb allows to create two types of command `hooks` which will be either executed -before or after a certain command. - +Gdb allows to create two types of command `hooks` +- `hook-` will be run before `` +- `hookpost-` will be run after `` ```markdown - define hook- Run commands defined in hook before - # cmds executing . + define hook- + # cmds end - define hookpost- Run commands defined in hookpost after - # cmds executing . + define hookpost- + # cmds end ``` -# Flows +# Examples -## Catch SIGSEGV and execute commands on occurrence +## Catch SIGSEGV and execute commands +This creates a `catchpoint` for the `SIGSEGV` signal and attached the `command` +to it. ```markdown catch signal SIGSEGV command @@ -117,8 +123,9 @@ before or after a certain command. ``` ## Script gdb for automating debugging sessions +To script gdb add commands into a file and pass it to gdb via `-x`. +For example create `run.gdb`: ```markdown -# run.gdb set pagination off break mmap @@ -133,21 +140,23 @@ before or after a certain command. ``` This script can be used as: ```markdown - gdb -p -x ./run.gdb --batch &> run.log + gdb --batch -x ./run.gdb -p ``` +# Know Bugs + ## Workaround `command + finish` bug -When using `finish` action inside a `command` block, actions after `finish` are -not executed anymore. To workaround that bug one can create a wrapper function -which calls `finish`. +When using `finish` inside a `command` block, commands after `finish` are not +executed. To workaround that bug one can create a wrapper function which calls +`finish`. ```markdown define handler - bt - finish - info reg rax + bt + finish + info reg rax end command - handler + handler end ``` -- cgit v1.2.3