Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: "Fred Viles" <fv@epitools.com>
To: Gdb List <gdb@sources.redhat.com>
Subject: Re: question about c-lang.c
Date: Thu, 12 Sep 2002 17:17:00 -0000	[thread overview]
Message-ID: <3D80CC09.15975.F8BDA8@localhost> (raw)
In-Reply-To: <3D810AC7.5040306@ges.redhat.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



  reply	other threads:[~2002-09-13  0:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-10 16:29 Tom Tromey
2002-09-12 14:44 ` Andrew Cagney
2002-09-12 17:17   ` Fred Viles [this message]
2002-09-12 18:53     ` Tom Tromey
2002-09-12 19:05       ` Andrew Cagney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3D80CC09.15975.F8BDA8@localhost \
    --to=fv@epitools.com \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox