From d5772f62300453d98ad0cfa8334efe0b62a7d157 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Wed, 27 Mar 2024 19:54:33 +0100 Subject: gdb: log overwrite + shell commands --- src/tools/gdb.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/tools/gdb.md b/src/tools/gdb.md index 7a630df..17d335c 100644 --- a/src/tools/gdb.md +++ b/src/tools/gdb.md @@ -184,6 +184,16 @@ thread name Switch to inferior with . ``` +## Shell commands +```markdown + shell + Run the shell_cmd and print the output, can also contain a pipeline. + + pipe | + Evaluate the gdb_cmd and run the shell_cmd which receives the output + of the gdb_cmd via stdin. +``` + ## Source file locations ```markdown dir @@ -228,7 +238,12 @@ thread name set logging redirect on: only log to file. off: log to file and tty. + + set logging overwrite + on: Truncate log file on each run. + off: Append to logfile (default). ``` +> Logging options should be configured before logging is turned on. # Text user interface (TUI) ```markdown @@ -434,6 +449,23 @@ set (s=0x7fffffffe594, v=3) at test.c:5 5 } ``` +## Shell commands +```markdown +# Run shell commands. + +(gdb) shell zcat /proc/config.gz | grep CONFIG_KVM= +CONFIG_KVM=m + +# Pipe gdb command to shell command. + +(gdb) pipe info proc mapping | grep libc + 0x7ffff7a1a000 0x7ffff7a42000 0x28000 0x0 r--p /usr/lib/libc.so.6 + 0x7ffff7a42000 0x7ffff7b9d000 0x15b000 0x28000 r-xp /usr/lib/libc.so.6 + 0x7ffff7b9d000 0x7ffff7bf2000 0x55000 0x183000 r--p /usr/lib/libc.so.6 + 0x7ffff7bf2000 0x7ffff7bf6000 0x4000 0x1d7000 r--p /usr/lib/libc.so.6 + 0x7ffff7bf6000 0x7ffff7bf8000 0x2000 0x1db000 rw-p /usr/lib/libc.so.6 +``` + # Know Bugs ## Workaround `command + finish` bug -- cgit v1.2.3