In reference of my original problem:
http://sources.redhat.com/ml/bug-gdb/2000-09/msg00012.html
I used gdb to single-step gdb 5.0 itself, and I was able to put
a breakpoint in memory_error(). When I try to print the value
of 's', of type string, I get this:
(gdb) print s
Breakpoint 3, memory_error (status=5, memaddr=0) at corefile.c:239
Line number 239 out of range; corefile.c has 106 lines.
(top-gdb) where
#0 memory_error (status=5, memaddr=0) at corefile.c:239
#1 0x80b3fa9 in read_memory_section (memaddr=0, myaddr=0x83bbcfc "", len=4,
bfd_section=0x0) at corefile.c:283
#2 0x80768f2 in value_at (type=0x81f9598, addr=0, sect=0x0) at valops.c:468
#3 0x80715d1 in value_static_field (type=0x82264c0, fieldno=0) at values.c:773
#4 0x80baddf in cp_print_value_fields (type=0x82264c0, real_type=0x82264c0,
valaddr=0x83bbba4 "PÄ\004\b2.1.3/elP", offset=0, address=3221223428,
stream=0x81d28f8, format=0, recurse=0, pretty=Val_no_prettyprint,
dont_print_vb=0x0, dont_print_statmem=0) at cp-valprint.c:384
#5 0x80b9f5c in c_val_print (type=0x822642c,
valaddr=0x83bbba4 "PÄ\004\b2.1.3/elP", embedded_offset=0,
address=3221223428, stream=0x81d28f8, format=0, deref_ref=1, recurse=0,
pretty=Val_no_prettyprint) at c-valprint.c:305
#6 0x807d70d in val_print (type=0x822642c,
valaddr=0x83bbba4 "PÄ\004\b2.1.3/elP", embedded_offset=0,
address=3221223428, stream=0x81d28f8, format=0, deref_ref=1, recurse=0,
pretty=Val_pretty_default) at valprint.c:158
#7 0x80ba530 in c_value_print (val=0x83bbb68, stream=0x81d28f8, format=0,
pretty=Val_pretty_default) at c-valprint.c:556
#8 0x807d76e in value_print (val=0x83bbb68, stream=0x81d28f8, format=0,
pretty=Val_pretty_default) at valprint.c:184
#9 0x807ec74 in print_formatted (val=0x83bbb68, format=0, size=0,
stream=0x81d28f8) at printcmd.c:331
#10 0x807f9dc in print_command_1 (exp=0x81d2892 "s", inspect=0, voidprint=1)
at printcmd.c:983
#11 0x807fa4e in print_command (exp=0x81d2892 "s", from_tty=1)
at printcmd.c:1006
#12 0x80becc6 in execute_command (p=0x81d2892 "s", from_tty=1) at top.c:1546
#13 0x8096e16 in command_handler (command=0x81d2890 "p s") at event-top.c:515
In value_static_field() (frame 3), the first if() succeeds.
Then, the variable 'addr' gets the value zero.
This is with the default debugging format, stabs. With -gdwarf-2,
the problem disappears with this particular (small) program. However,
the problem reappears in a much larger program even with -gdwarf-2.
Notes:
- I suppose that gdb 5.0 should work even with the stabs format;
- I have not recompiled g++ 2.95.2 since I installed gdb 5.0; I don't
know if this matters.
--
Pierre Sarrazin <sarrazip at machinasapiens dot com>