diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-11-09 11:40:55 +0100 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-11-09 11:40:55 +0100 |
commit | cec6cc310a499c8f5659052b70eb0211bccb109f (patch) | |
tree | 14a71f830315a1bc278e9f631bac6fc8cb598a31 | |
parent | 8c7f8b75acf4eb4fc0e8d606cffa4bcdae865606 (diff) | |
download | notes-cec6cc310a499c8f5659052b70eb0211bccb109f.tar.gz notes-cec6cc310a499c8f5659052b70eb0211bccb109f.zip |
gdb: trace-commands, exec-wrapper
-rw-r--r-- | src/debug/gdb.md | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/debug/gdb.md b/src/debug/gdb.md index 41d26f7..61bc9dd 100644 --- a/src/debug/gdb.md +++ b/src/debug/gdb.md @@ -258,11 +258,18 @@ thread name <name> on: Truncate log file on each run. off: Append to logfile (default). + set trace-commands <on | off> + on: Echo comamands executed (good with logging). + off: Do not echo commands executedt (default). + set history filename <fname> Change file where to save and restore command history to and from. set history <on | off> Enable or disable saving of command history. + + set exec-wrapper <cli> + Set an exec wrapper which sets up the env and execs the debugee. ``` > Logging options should be configured before logging is turned on. @@ -505,4 +512,34 @@ executed. To workaround that bug one can create a wrapper function which calls end ``` +## Launch debuggee through an exec wrapper +```markdown +> cat test.c +#include <stdio.h> +#include <stdlib.h> + +int main() { + const char* env = getenv("MOOSE"); + printf("$MOOSE=%s\n", env ? env : "<nullptr>"); +} + +> cat test.sh +#!/bin/bash + +echo "running test.sh wapper" +export MOOSE=moose +exec ./test + +> gcc -g -o test test.c + +> gdb test +(gdb) r +$MOOSE=<nullptr> + +(gdb) set exec-wrapper bash test.sh +(gdb) r +running test.sh wapper +$MOOSE=moose +``` + [gdb-convenience-vars]: https://sourceware.org/gdb/onlinedocs/gdb/Convenience-Vars.html#Convenience-Vars |