Chapter 3. A Sample gdb Session
9
#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);
The last line displayed looks a little odd; 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
(
) to see
their values.
(gdb)
p lquote
$1 = 0x35d40 "
QUOTE
"
(gdb)
p rquote
$2 = 0x35d50 "
UNQUOTE
"
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
Содержание ENTERPRISE LINUX 4 - DEVELOPER TOOLS GUIDE
Страница 1: ...Red Hat Enterprise Linux 4 Debugging with gdb ...
Страница 12: ...2 Chapter 1 Debugging with gdb ...
Страница 28: ...18 Chapter 4 Getting In and Out of gdb ...
Страница 34: ...24 Chapter 5 gdb Commands ...
Страница 44: ...34 Chapter 6 Running Programs Under gdb ...
Страница 68: ...58 Chapter 8 Examining the Stack ...
Страница 98: ...88 Chapter 10 Examining Data ...
Страница 112: ...102 Chapter 12 Tracepoints ...
Страница 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Страница 138: ...128 Chapter 14 Using gdb with Different Languages ...
Страница 144: ...134 Chapter 15 Examining the Symbol Table ...
Страница 170: ...160 Chapter 19 Debugging remote programs ...
Страница 198: ...188 Chapter 21 Controlling gdb ...
Страница 204: ...194 Chapter 22 Canned Sequences of Commands ...
Страница 206: ...196 Chapter 23 Command Interpreters ...
Страница 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Страница 296: ...286 Chapter 27 gdb Annotations ...
Страница 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Страница 322: ...312 Chapter 30 Using History Interactively ...
Страница 362: ...352 Appendix D gdb Remote Serial Protocol ...
Страница 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Страница 386: ...376 Appendix G GNU Free Documentation License ...
Страница 410: ......