From 07dda6914ac1354b53da50d1b43cf439102c1bcc Mon Sep 17 00:00:00 2001 From: johannst Date: Sat, 9 Nov 2024 10:42:31 +0000 Subject: deploy: 3d599bcbf6771def1076c3e9561bc748956dfc94 --- print.html | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'print.html') diff --git a/print.html b/print.html index 792c807..3f180a5 100644 --- a/print.html +++ b/print.html @@ -2760,11 +2760,25 @@ renice -n 5 -p PID -o <file> ... log output into <file> -l <filter> . show who calls into lib matched by <filter> -C .......... demangle + -x <filter> . which symbol table entry points to trace + (can be of form sym_pattern@lib_pattern)

Example

List which program/libs call into libstdc++:

ltrace -l '*libstdc++*' -C -o ltrace.log ./main
 
+

Trace symbols from dlopen(3)ed libraries.

+
# Assume libfoo.so would be dynamically loaded via dlopen.
+ltrace -x '@libfoo.so'
+
+# Trace all dlopened symbols.
+ltrace -x '*'
+# Trace all symbols from dlopened libraries which name match the
+# pattern "liby*".
+ltrace -x '@liby*'
+# Trace symbol "foo" from all dlopened libraries matching the pattern.
+ltrace -x 'foo@liby*'
+

perf(1)

perf list     show supported hw/sw events & metrics
   -v ........ print longer event descriptions
@@ -3319,11 +3333,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.

@@ -3534,6 +3555,34 @@ executed. To workaround that bug one can create a wrapper function which calls handler end +

Launch debuggee through an exec wrapper

+
> 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
+

gdbserver(1)

CLI

  gdbserver [opts] comm prog [args]
-- 
cgit v1.2.3