Example:
@smallexample
@group
-(gdb) p var
+(@value{GDBP}) p var
$1 = @{
black = 144,
red = 233,
@}
@end group
@group
-(gdb) pipe p var|wc
+(@value{GDBP}) pipe p var|wc
7 19 80
-(gdb) |p var|wc -l
+(@value{GDBP}) |p var|wc -l
7
@end group
@group
-(gdb) p /x var
+(@value{GDBP}) p /x var
$4 = @{
black = 0x90,
red = 0xe9,
blue = 0x262,
white = 0x3db
@}
-(gdb) ||grep red
+(@value{GDBP}) ||grep red
red => 0xe9,
@end group
@group
-(gdb) | -d ! echo this contains a | char\n ! sed -e 's/|/PIPE/'
+(@value{GDBP}) | -d ! echo this contains a | char\n ! sed -e 's/|/PIPE/'
this contains a PIPE char
-(gdb) | -d xxx echo this contains a | char!\n xxx sed -e 's/|/PIPE/'
+(@value{GDBP}) | -d xxx echo this contains a | char!\n xxx sed -e 's/|/PIPE/'
this contains a PIPE char!
-(gdb)
+(@value{GDBP})
@end group
@end smallexample
@end table
session. For example, to change the limit of array elements to print,
you can do the following:
@smallexample
-(@value{GDBN}) set print elements 10
-(@value{GDBN}) print some_array
+(@value{GDBP}) set print elements 10
+(@value{GDBP}) print some_array
$1 = @{0, 10, 20, 30, 40, 50, 60, 70, 80, 90...@}
@end smallexample
print} subcommands. @xref{print options}. The example above could be
rewritten as:
@smallexample
-(@value{GDBN}) print -elements 10 -- some_array
+(@value{GDBP}) print -elements 10 -- some_array
$1 = @{0, 10, 20, 30, 40, 50, 60, 70, 80, 90...@}
@end smallexample
For example, the command
@smallexample
-(@value{GDBN}) with print array on -- print some_array
+(@value{GDBP}) with print array on -- print some_array
@end smallexample
@noindent
is equivalent to the following 3 commands:
@smallexample
-(@value{GDBN}) set print array on
-(@value{GDBN}) print some_array
-(@value{GDBN}) set print array off
+(@value{GDBP}) set print array on
+(@value{GDBP}) print some_array
+(@value{GDBP}) set print array off
@end smallexample
The @code{with} command is particularly useful when you want to
defined in Python or Guile. @xref{Extending GDB,, Extending GDB}.
@smallexample
-(@value{GDBN}) with print pretty on -- my_complex_command
+(@value{GDBP}) with print pretty on -- my_complex_command
@end smallexample
To change several settings for the same command, you can nest
is the LWP id.
@smallexample
-(@value{GDBN}) thread find 26688
+(@value{GDBP}) thread find 26688
Thread 4 has target id 'Thread 0x41e02940 (LWP 26688)'
-(@value{GDBN}) info thread 4
+(@value{GDBP}) info thread 4
Id Target Id Frame
4 Thread 0x41e02940 (LWP 26688) 0x00000031ca6cd372 in select ()
@end smallexample
@smallexample
(@value{GDBP}) info inferiors
-(gdb) info inferior
+(@value{GDBP}) info inferior
Id Description Executable
* 1 <null> prog1
(@value{GDBP}) run
you could do the following:
@example
-(gdb) set dprintf-style call
-(gdb) set dprintf-function fprintf
-(gdb) set dprintf-channel mylog
-(gdb) dprintf 25,"at line 25, glob=%d\n",glob
+(@value{GDBP}) set dprintf-style call
+(@value{GDBP}) set dprintf-function fprintf
+(@value{GDBP}) set dprintf-channel mylog
+(@value{GDBP}) dprintf 25,"at line 25, glob=%d\n",glob
Dprintf 1 at 0x123456: file main.c, line 25.
-(gdb) info break
+(@value{GDBP}) info break
1 dprintf keep y 0x00123456 in main at main.c:25
call (void) fprintf (mylog,"at line 25, glob=%d\n",glob)
continue
-(gdb)
+(@value{GDBP})
@end example
Note that the @code{info break} displays the dynamic printf commands
over when stepping.
@smallexample
-(gdb) skip -gfi utils/*.c
+(@value{GDBP}) skip -gfi utils/*.c
@end smallexample
@item -function @var{linespec}
regular expression makes this easier.
@smallexample
-(gdb) skip -rfu ^std::(allocator|basic_string)<.*>::~?\1 *\(
+(@value{GDBP}) skip -rfu ^std::(allocator|basic_string)<.*>::~?\1 *\(
@end smallexample
If you want to skip every templated C@t{++} constructor and destructor
in the @code{std} namespace you can do:
@smallexample
-(gdb) skip -rfu ^std::([a-zA-z0-9_]+)<.*>::~?\1 *\(
+(@value{GDBP}) skip -rfu ^std::([a-zA-z0-9_]+)<.*>::~?\1 *\(
@end smallexample
@end table
will be skipped over when stepping.
@smallexample
-(gdb) skip file boring.c
+(@value{GDBP}) skip file boring.c
File boring.c will be skipped when stepping.
@end smallexample
supports.
@smallexample
-(gdb) info record
+(@value{GDBP}) info record
Active record target: record-btrace
Recording format: Intel Processor Trace.
Buffer size: 16kB.
Failed to configure the Intel Processor Trace decoder: unknown cpu.
-(gdb) set record btrace cpu intel:6/158
-(gdb) info record
+(@value{GDBP}) set record btrace cpu intel:6/158
+(@value{GDBP}) info record
Active record target: record-btrace
Recording format: Intel Processor Trace.
Buffer size: 16kB.
@command{info frame}, for example:
@smallexample
-(gdb) info frame
+(@value{GDBP}) info frame
Stack level 1, frame at 0x7fffffffda30:
rip = 0x40066d in b (amd64-entry-value.cc:59); saved rip 0x4004c5
tail call frame, caller of frame at 0x7fffffffda30
@smallexample
@group
-(gdb) frame apply all p j
+(@value{GDBP}) frame apply all p j
#0 some_function (i=5) at fun.c:4
No symbol "j" in current context.
-(gdb) frame apply all -c p j
+(@value{GDBP}) frame apply all -c p j
#0 some_function (i=5) at fun.c:4
No symbol "j" in current context.
#1 0x565555fb in main (argc=1, argv=0xffffd2c4) at fun.c:11
$1 = 5
-(gdb) frame apply all -s p j
+(@value{GDBP}) frame apply all -s p j
#1 0x565555fb in main (argc=1, argv=0xffffd2c4) at fun.c:11
$2 = 5
-(gdb)
+(@value{GDBP})
@end group
@end smallexample
@smallexample
@group
-(gdb) frame apply all p $sp
+(@value{GDBP}) frame apply all p $sp
#0 some_function (i=5) at fun.c:4
$4 = (void *) 0xffffd1e0
#1 0x565555fb in main (argc=1, argv=0xffffd2c4) at fun.c:11
$5 = (void *) 0xffffd1f0
-(gdb)
+(@value{GDBP})
@end group
@end smallexample
If the flag @code{-q} is given, no frame information is printed:
@smallexample
@group
-(gdb) frame apply all -q p $sp
+(@value{GDBP}) frame apply all -q p $sp
$12 = (void *) 0xffffd1e0
$13 = (void *) 0xffffd1f0
-(gdb)
+(@value{GDBP})
@end group
@end smallexample
Example:
@smallexample
-(gdb) info frame-filter
+(@value{GDBP}) info frame-filter
global frame-filters:
Priority Enabled Name
Priority Enabled Name
999 Yes BuildProgramFilter
-(gdb) disable frame-filter /build/test BuildProgramFilter
-(gdb) info frame-filter
+(@value{GDBP}) disable frame-filter /build/test BuildProgramFilter
+(@value{GDBP}) info frame-filter
global frame-filters:
Priority Enabled Name
Priority Enabled Name
999 No BuildProgramFilter
-(gdb) enable frame-filter global PrimaryFunctionFilter
-(gdb) info frame-filter
+(@value{GDBP}) enable frame-filter global PrimaryFunctionFilter
+(@value{GDBP}) info frame-filter
global frame-filters:
Priority Enabled Name
Example:
@smallexample
-(gdb) info frame-filter
+(@value{GDBP}) info frame-filter
global frame-filters:
Priority Enabled Name
Priority Enabled Name
999 No BuildProgramFilter
-(gdb) set frame-filter priority global Reverse 50
-(gdb) info frame-filter
+(@value{GDBP}) set frame-filter priority global Reverse 50
+(@value{GDBP}) info frame-filter
global frame-filters:
Priority Enabled Name
Here is another example showing raw instructions in hex for AMD x86-64,
@smallexample
-(gdb) disas /r 0x400281,+10
+(@value{GDBP}) disas /r 0x400281,+10
Dump of assembler code from 0x400281 to 0x40028b:
0x0000000000400281: 38 36 cmp %dh,(%rsi)
0x0000000000400283: 2d 36 34 2e 73 sub $0x732e3436,%eax
@code{explore} command as follows.
@smallexample
-(gdb) explore cs
+(@value{GDBP}) explore cs
The value of `cs' is a struct/class of type `struct ComplexStruct' with
the following fields:
@code{struct ComplexStruct} to the @code{explore} command.
@smallexample
-(gdb) explore struct ComplexStruct
+(@value{GDBP}) explore struct ComplexStruct
@end smallexample
@noindent
@smallexample
Breakpoint 1, d (i=30) at gdb.base/entry-value.c:29
29 i++;
-(gdb) next
+(@value{GDBP}) next
30 e (i);
-(gdb) print i
+(@value{GDBP}) print i
$1 = 31
-(gdb) print i@@entry
+(@value{GDBP}) print i@@entry
$2 = 30
@end smallexample
You get during debugging
@smallexample
-(gdb) print var0
+(@value{GDBP}) print var0
$1 = "A"
-(gdb) print var1
+(@value{GDBP}) print var1
$2 = @{65 'A', 0 '\0'@}
@end smallexample
the structure that are visible, for example
@smallexample
-(gdb) set print max-depth 2
-(gdb) p var
+(@value{GDBP}) set print max-depth 2
+(@value{GDBP}) p var
$1 = @{d = @{c = @{...@}@}@}
-(gdb) p var.d
+(@value{GDBP}) p var.d
$2 = @{c = @{b = @{...@}@}@}
-(gdb) p var.d.c
+(@value{GDBP}) p var.d.c
$3 = @{b = @{a = 3@}@}
@end smallexample
Example:
@smallexample
-(gdb) backtrace
+(@value{GDBP}) backtrace
#0 bottom_func ()
at testsuite/gdb.python/py-caller-is.c:21
#1 0x00000000004005a0 in middle_func ()
at testsuite/gdb.python/py-caller-is.c:33
#3 0x00000000004005b6 in main ()
at testsuite/gdb.python/py-caller-is.c:39
-(gdb) print $_caller_is ("middle_func")
+(@value{GDBP}) print $_caller_is ("middle_func")
$1 = 1
-(gdb) print $_caller_is ("top_func", 2)
+(@value{GDBP}) print $_caller_is ("top_func", 2)
$1 = 1
@end smallexample
an enumerated type:
@smallexample
-(gdb) printf "Visiting node of type %s\n", $_as_string(node)
+(@value{GDBP}) printf "Visiting node of type %s\n", $_as_string(node)
Visiting node of type NODE_INTEGER
@end smallexample
you get during debugging:
@smallexample
-(gdb) find &hello[0], +sizeof(hello), "hello"
+(@value{GDBP}) find &hello[0], +sizeof(hello), "hello"
0x804956d <hello.1620+6>
1 pattern found
-(gdb) find &hello[0], +sizeof(hello), 'h', 'e', 'l', 'l', 'o'
+(@value{GDBP}) find &hello[0], +sizeof(hello), 'h', 'e', 'l', 'l', 'o'
0x8049567 <hello.1620>
0x804956d <hello.1620+6>
2 patterns found.
-(gdb) find &hello[0], +sizeof(hello), @{char[5]@}"hello"
+(@value{GDBP}) find &hello[0], +sizeof(hello), @{char[5]@}"hello"
0x8049567 <hello.1620>
0x804956d <hello.1620+6>
2 patterns found.
-(gdb) find /b1 &hello[0], +sizeof(hello), 'h', 0x65, 'l'
+(@value{GDBP}) find /b1 &hello[0], +sizeof(hello), 'h', 0x65, 'l'
0x8049567 <hello.1620>
1 pattern found
-(gdb) find &mixed, +sizeof(mixed), (char) 'c', (short) 0x1234, (int) 0x87654321
+(@value{GDBP}) find &mixed, +sizeof(mixed), (char) 'c', (short) 0x1234, (int) 0x87654321
0x8049560 <mixed.1625>
1 pattern found
-(gdb) print $numfound
+(@value{GDBP}) print $numfound
$1 = 1
-(gdb) print $_
+(@value{GDBP}) print $_
$2 = (void *) 0x8049560
@end smallexample
kind by text @code{tail call frame} such as in this sample @value{GDBN} output:
@smallexample
-(gdb) x/i $pc - 2
+(@value{GDBP}) x/i $pc - 2
0x40066b <b(int, double)+11>: jmp 0x400640 <c(int, double)>
-(gdb) info frame
+(@value{GDBP}) info frame
Stack level 1, frame at 0x7fffffffda30:
rip = 0x40066d in b (amd64-entry-value.cc:59); saved rip 0x4004c5
tail call frame, caller of frame at 0x7fffffffda30
DW_TAG_call_site 0x40039a in main
a () at t.c:3
3 static void __attribute__((noinline, noclone)) a (void) @{ x++; @}
-(gdb) bt
+(@value{GDBP}) bt
#0 a () at t.c:3
#1 0x000000000040039a in main () at t.c:5
@end smallexample
tailcall: initial: 0x4004d2(a) 0x4004ce(b) 0x4004b2(c) 0x4004a2(d)
tailcall: compare: 0x4004d2(a) 0x4004cc(b) 0x400492(e)
tailcall: reduced: 0x4004d2(a) |
-(gdb) bt
+(@value{GDBP}) bt
#0 f () at t.c:2
#1 0x00000000004004d2 in a () at t.c:8
#2 0x0000000000400395 in main () at t.c:9
@{ if (i) b (i - 1); else c (0); @}
int main (void) @{ a (5); return 0; @}
-(gdb) bt
+(@value{GDBP}) bt
#0 c (i=i@@entry=0) at t.c:2
#1 0x0000000000400428 in a (DW_OP_entry_value resolving has found
function "a" at 0x400420 can call itself via tail calls
tag. For example:
@smallexample
-(gdb) b function(int)
+(@value{GDBP}) b function(int)
Breakpoint 2 at 0x40060d: file main.cc, line 10.
-(gdb) info breakpoints
+(@value{GDBP}) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x0040060d in function[abi:cxx11](int)
at main.cc:10
When stopped inside @code{main} either of these work:
@example
-(gdb) p myglob
-(gdb) p main.myglob
+(@value{GDBP}) p myglob
+(@value{GDBP}) p main.myglob
@end example
@cindex builtin Go types
need to resolve the type can be achieved.
@smallexample
-(gdb) compile code static struct a @{ int a; @} v = @{ 42 @}; argv = &v;
-(gdb) compile code printf ("%d\n", ((struct a *) argv)->a);
+(@value{GDBP}) compile code static struct a @{ int a; @} v = @{ 42 @}; argv = &v;
+(@value{GDBP}) compile code printf ("%d\n", ((struct a *) argv)->a);
gdb command line:1:36: error: dereferencing pointer to incomplete type ‘struct a’
Compilation failed.
-(gdb) compile code struct a @{ int a; @}; printf ("%d\n", ((struct a *) argv)->a);
+(@value{GDBP}) compile code struct a @{ int a; @}; printf ("%d\n", ((struct a *) argv)->a);
42
@end smallexample
that lies within the boundaries of this symbol file in memory. Example:
@smallexample
-(gdb) add-symbol-file /home/user/gdb/mylib.so 0x7ffff7ff9480
+(@value{GDBP}) add-symbol-file /home/user/gdb/mylib.so 0x7ffff7ff9480
add symbol table from file "/home/user/gdb/mylib.so" at
.text_addr = 0x7ffff7ff9480
(y or n) y
Reading symbols from /home/user/gdb/mylib.so...
-(gdb) remove-symbol-file -a 0x7ffff7ff9480
+(@value{GDBP}) remove-symbol-file -a 0x7ffff7ff9480
Remove symbol table from file "/home/user/gdb/mylib.so"? (y or n) y
-(gdb)
+(@value{GDBP})
@end smallexample
with ssh:
@smallexample
-(gdb) target remote | ssh -T hostname gdbserver - hello
+(@value{GDBP}) target remote | ssh -T hostname gdbserver - hello
@end smallexample
The @samp{-T} option to ssh is provided because we don't need a remote pty,
tty for standard input and output as well as two network sockets:
@smallexample
-(gdb) info proc files 22136
+(@value{GDBP}) info proc files 22136
process 22136
Open files:
For example:
@smallexample
-set extended-prompt Current working directory: \w (gdb)
+set extended-prompt Current working directory: \w (@value{GDBP})
@end smallexample
Note that when an extended-prompt is set, it takes control of the
or disabled.
@smallexample
-(gdb) show auto-load
+(@value{GDBP}) show auto-load
gdb-scripts: Auto-loading of canned sequences of commands scripts is on.
libthread-db: Auto-loading of inferior specific libthread_db is on.
local-gdbinit: Auto-loading of .gdbinit script from current directory
not.
@smallexample
-(gdb) info auto-load
+(@value{GDBP}) info auto-load
gdb-scripts:
Loaded Script
Yes /home/user/gdb/gdb-gdb.gdb
may not be too obvious while setting it up.
@smallexample
-(gdb) set debug auto-load on
-(gdb) file ~/src/t/true
+(@value{GDBP}) set debug auto-load on
+(@value{GDBP}) file ~/src/t/true
auto-load: Loading canned sequences of commands script "/tmp/true-gdb.gdb"
for objfile "/tmp/true".
auto-load: Updating directories of "/usr:/opt".
Example:
@example
-(gdb) define-prefix abc
-(gdb) define-prefix abc def
-(gdb) define abc def
+(@value{GDBP}) define-prefix abc
+(@value{GDBP}) define-prefix abc def
+(@value{GDBP}) define abc def
Type commands for definition of "abc def".
End with a line saying just "end".
>echo command initial def\n
>end
-(gdb) define abc def ghi
+(@value{GDBP}) define abc def ghi
Type commands for definition of "abc def ghi".
End with a line saying just "end".
>echo command ghi\n
>end
-(gdb) define abc def
+(@value{GDBP}) define abc def
Keeping subcommands of prefix command "def".
Redefine command "def"? (y or n) y
Type commands for definition of "abc def".
End with a line saying just "end".
>echo command def\n
>end
-(gdb) abc def ghi
+(@value{GDBP}) abc def ghi
command ghi
-(gdb) abc def
+(@value{GDBP}) abc def
command def
-(gdb)
+(@value{GDBP})
@end example
@kindex dont-repeat
named @samp{di}. The following will accomplish this.
@smallexample
-(gdb) alias -a di = disas
+(@value{GDBP}) alias -a di = disas
@end smallexample
Note that aliases are different from user-defined commands. With a
of a command.
@smallexample
-(gdb) alias -a set print elms = set print elements
-(gdb) alias -a show print elms = show print elements
-(gdb) set p elms 200
-(gdb) show p elms
+(@value{GDBP}) alias -a set print elms = set print elements
+(@value{GDBP}) alias -a show print elms = show print elements
+(@value{GDBP}) set p elms 200
+(@value{GDBP}) show p elms
Limit on string chars or array elements to print is 200.
@end smallexample
@var{alias}, just as they are normally.
@smallexample
-(gdb) alias -a set pr elms = set p ele
+(@value{GDBP}) alias -a set pr elms = set p ele
@end smallexample
Finally, here is an example showing the creation of a one word
This creates alias @samp{spe} of the command @samp{set print elements}.
@smallexample
-(gdb) alias spe = set print elements
-(gdb) spe 20
+(@value{GDBP}) alias spe = set print elements
+(@value{GDBP}) spe 20
@end smallexample
@menu
Here is an example of the resulting disassembly:
@smallexample
-(gdb) info addr argc
+(@value{GDBP}) info addr argc
Symbol "argc" is a complex DWARF expression:
1: DW_OP_fbreg 0
@end smallexample
One can fetch individual fields like in @samp{C}.
@smallexample
-(gdb) print $my_struct_reg.field3
+(@value{GDBP}) print $my_struct_reg.field3
$1 = 42
@end smallexample
would be printed as:
@smallexample
-(gdb) info register flags
+(@value{GDBP}) info register flags
flags 0x3 [ X LEVEL=high ]
@end smallexample
@smallexample
@ifset man
@c @file would wrap it as F</dev/ttyb>.
-(gdb) target remote /dev/ttyb
+(@value{GDBP}) target remote /dev/ttyb
@end ifset
@ifclear man
-(gdb) target remote @file{/dev/ttyb}
+(@value{GDBP}) target remote @file{/dev/ttyb}
@end ifclear
@end smallexample
communicates with the server via serial line @file{/dev/ttyb}, and:
@smallexample
-(gdb) target remote the-target:2345
+(@value{GDBP}) target remote the-target:2345
@end smallexample
@noindent
In such case use the @code{extended-remote} @value{GDBN} command variant:
@smallexample
-(gdb) target extended-remote the-target:2345
+(@value{GDBP}) target extended-remote the-target:2345
@end smallexample
The @command{gdbserver} option @option{--multi} may or may not be used in such