Debugging with GDB Manual HP WDB v6.3 (5900-2180, August 2012)
(which can also be spelled bt), to see where we are in the stack as a whole: the backtrace
command displays a stack frame for each active subroutine.
((gdb)) bt
#0 set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
at input.c:530
#1 0x6344 in m4_changequote (argc=3, argv=0x33c70)
at builtin.c:882
#2 0x8174 in expand_macro (sym=0x33320) at macro.c:242
#3 0x7a88 in expand_token (obs=0x0, t=209696, td=0xf7fffa30)
at macro.c:71
#4 0x79dc in expand_input () at macro.c:40
#5 0x2930 in main (argc=0, argv=0xf7fffb20) at m4.c:195
We step through a few more lines to see what happens. The first two times, we can use 's'; the
next two times we use n to avoid falling into the xstrdup subroutine.
((gdb)) s
0x3b5c 532 if (rquote != def_rquote)
((gdb)) s
0x3b80 535 lquote = (lq == nil || *lq == '\0') ? \
def_lquote : xstrdup(lq);
((gdb)) n
536 rquote = (rq == nil || *rq == '\0') ? def_rquote\
: xstrdup(rq);
((gdb)) n
538 len_lquote = strlen(rquote);
1.8 Printing Variable Values
The last line displayed looks a little odd in the listing above; we can examine the variables lquote
and rquote to see if they are in fact the new left and right quotes we specified. We use the
command p (print) to view their values.
((gdb)) p lquote
$1 = 0x35d40 "<QUOTE>"
((gdb)) p rquote
$2 = 0x35d50 "<UNQUOTE>"
1.9 Listing Source Code
lquote and rquote are indeed the new left and right quotes. To look at some context, we can
display ten lines of source surrounding the current line with the l (list) command.
((gdb)) l
533 xfree(rquote);
534
535 lquote = (lq == nil || *lq == '\0') ? def_lquote\
: xstrdup (lq);
536 rquote = (rq == nil || *rq == '\0') ? def_rquote\
: xstrdup (rq);
537
538 len_lquote = strlen(rquote);
539 len_rquote = strlen(lquote);
540 }
541
542 void
Let us step past the two lines that set len_lquote and len_rquote, and then examine the values
of those variables.
((gdb)) n
539 len_rquote = strlen(lquote);
((gdb)) n
540 }
((gdb)) p len_lquote
$3 = 9
1.8 Printing Variable Values 19