((gdb)) n
882 set_quotes((argc >= 2) ? TOKEN_DATA_TEXT(argv[1])\
: nil,
1.6 Stepping into a subroutine
The set_quotes looks like a promising subroutine. We can go into it by using the
command s (step) instead of next. step goes to the next line to be executed in any
subroutine, so it steps into set_quotes.
((gdb)) s
set_quotes (lq=0x34c78 "<QUOTE>", rq=0x34c88 "<UNQUOTE>")
at input.c:530
530 if (lquote != def_lquote)
1.7 Examining the Stack
The display that shows the subroutine where m4 is now suspended (and its arguments)
is called a stack frame display. It shows a summary of the stack. We can use the
backtrace command (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.
1.6 Stepping into a subroutine 21