This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: question about c-lang.c
- From: "Fred Viles" <fv at epitools dot com>
- To: Gdb List <gdb at sources dot redhat dot com>
- Date: Thu, 12 Sep 2002 17:16:57 -0700
- Subject: Re: question about c-lang.c
- Organization: Embedded Performance, Inc.
- Reply-to: fv at epitools dot com
On 12 Sep 2002 at 17:44, Andrew Cagney wrote about
"Re: question about c-lang.c":
| > Today I happened to read c-lang.c:c_emit_char().
| >
| > Suppose a string contains the characters \0 (nul), `0' and finally `1'.
| > (See appended source.)
| >
| > Now print this string:
| >
| > (gdb) p *c @ 4
| > $2 = "\001"
| >
| > This output is ambiguous, as \001 has another meaning.
|
| Isn't it simply wrong? A C parser would treat that as '\1'.
Right.
|...
| > I've appended one possible fix. This isn't ideal since it also
| > changes how char literals are printed. Perhaps that is acceptable?
|
| How are char literals changed?
Looks to me like c_emit_char() is called both for char and string
cases. So char c = '\0'; would result in
(gdb) print c
$1 = '\000'
rather than
$1 = '\0'
>From the change log, it looks like GDB used to work this way and was
patched last December to get the current (wrong for strings)
behavior.
Maybe making the output conditional on (quoter == '\'') would allow
for both cases.
- Fred