aboutsummaryrefslogtreecommitdiffhomepage
path: root/debug/gdb.html
diff options
context:
space:
mode:
Diffstat (limited to 'debug/gdb.html')
-rw-r--r--debug/gdb.html35
1 files changed, 35 insertions, 0 deletions
diff --git a/debug/gdb.html b/debug/gdb.html
index b73a03d..bac580a 100644
--- a/debug/gdb.html
+++ b/debug/gdb.html
@@ -386,11 +386,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.
</code></pre>
<blockquote>
<p>Logging options should be configured before logging is turned on.</p>
@@ -601,6 +608,34 @@ executed. To workaround that bug one can create a wrapper function which calls
handler
end
</code></pre>
+<h2 id="launch-debuggee-through-an-exec-wrapper"><a class="header" href="#launch-debuggee-through-an-exec-wrapper">Launch debuggee through an exec wrapper</a></h2>
+<pre><code class="language-markdown">&gt; cat test.c
+#include &lt;stdio.h&gt;
+#include &lt;stdlib.h&gt;
+
+int main() {
+ const char* env = getenv("MOOSE");
+ printf("$MOOSE=%s\n", env ? env : "&lt;nullptr&gt;");
+}
+
+&gt; cat test.sh
+#!/bin/bash
+
+echo "running test.sh wapper"
+export MOOSE=moose
+exec ./test
+
+&gt; gcc -g -o test test.c
+
+&gt; gdb test
+(gdb) r
+$MOOSE=&lt;nullptr&gt;
+
+(gdb) set exec-wrapper bash test.sh
+(gdb) r
+running test.sh wapper
+$MOOSE=moose
+</code></pre>
</main>