From 09fbbdde83fa792aa98eee0377971a9c5a7b8be5 Mon Sep 17 00:00:00 2001 From: johannst Date: Thu, 28 Mar 2024 18:31:33 +0000 Subject: deploy: d5772f62300453d98ad0cfa8334efe0b62a7d157 --- print.html | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) (limited to 'print.html') diff --git a/print.html b/print.html index df3cdad..c67a7b4 100644 --- a/print.html +++ b/print.html @@ -1916,6 +1916,14 @@ thread name <name> inferior <id> Switch to inferior with <id>. +

Shell commands

+
  shell <shell_cmd>
+          Run the shell_cmd and print the output, can also contain a pipeline.
+
+  pipe <gdb_cmd> | <shell_cmd>
+          Evaluate the gdb_cmd and run the shell_cmd which receives the output
+          of the gdb_cmd via stdin.
+

Source file locations

  dir <path>
           Add <path> to the beginning of the searh path for source files.
@@ -1956,7 +1964,14 @@ thread name <name>
   set logging redirect <on/off>
           on: only log to file.
           off: log to file and tty.
+
+  set logging overwrite <on/off>
+          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)

  C-x a     Toggle UI.
   C-l       Redraw UI (curses UI can be messed up after the debugee prints to
@@ -2133,6 +2148,21 @@ New value = 3
 set (s=0x7fffffffe594, v=3) at test.c:5
 5   }
 
+

Shell commands

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

When using finish inside a command block, commands after finish are not @@ -3465,12 +3495,43 @@ objdump -C --disassemble=foo::bar <bin>

c++filt(1)

Demangle symbol

-
  c++-filt <symbol_str>
+
  c++-filt [opts] <symbol_str>
+    -t    Try to also demangle types.
 

Demangle stream

For example dynamic symbol table:

  readelf -W --dyn-syms <elf> | c++filt
 
+

Demangle types

+
// file: type.cc
+#include <cstdio>
+#include <typeinfo>
+
+#define P(ty) printf(#ty " -> %s\n", typeid(ty).name())
+
+template <typename T = void>
+struct Foo {};
+
+int main() {
+  P(int);
+  P(unsigned char);
+  P(Foo<>);
+  P(Foo<int>);
+}
+
+

Build and run:

+
$ clang++ type.cc && ./a.out | c++filt
+int -> i
+unsigned char -> h
+Foo<> -> 3FooIvE
+Foo<int> -> 3FooIiE
+
+$ clang++ type.cc && ./a.out | c++filt -t
+int -> int
+unsigned char -> unsigned char
+Foo<> -> Foo<void>
+Foo<int> -> Foo<int>
+

c++

openstd cpp standards.

Source files of most examples is available here.

-- cgit v1.2.3