From: Joel Brobecker <brobecker@adacore.com>
To: Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFC] Support for const char and strings in stabs reader
Date: Tue, 23 Mar 2010 18:53:00 -0000 [thread overview]
Message-ID: <20100323185314.GA2882@adacore.com> (raw)
In-Reply-To: <000201cac54d$246dcdd0$6d496970$@muller@ics-cnrs.unistra.fr>
> 2010-03-16 Pierre Muller <muller@ics.u-strasbg.fr>
>
> * stabsread.c (define_symbol): Add support for char
> and string constants.
As a general comment, the formatting of the section supporting strings
is not consistent. It looks like it's because you have a mixture of
spaces and tabs...
> + case 's':
> + {
> + struct type *range_type;
> + char quote = *p++;
> + char *startp = p;
> + gdb_byte *string_value;
Can you add an empty line after your local variable declarations?
> + if (quote != '\'' && quote != '"')
> + {
> + SYMBOL_CLASS (sym) = LOC_CONST;
> + SYMBOL_TYPE (sym) = error_type (&p, objfile);
> + SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
> + add_symbol_to_list (sym, &file_symbols);
> + return sym;
> + }
> + /* Find matching quote, rejecting escaped quotes. */
> + while (*p && *p != quote)
> + {
> + if (*p == '\\')
> + p++;
> + if (*p)
> + p++;
> + }
What if you don't find the matching quote? I think we should reject
the stabs the same way you do when you don't find an opening quote.
> + *p = '\0';
Outch. I see that you restore the stabs later on, but I am still
concerned by this, particularly if any of the functions you use end up
raising an exception...
It looks like you do this mostly to be able to get the length of
the string itself. But that's easy to obtain, thanks to the loop
that searches the ending quote character.
> + strcpy ((char *)string_value, startp);
> + *p = quote;
One question I asked myself, and got confused over, is: What happens
with escaped quotes. For instance, let's imagine that we have the
following string: 'hello \' there'. I think that the string value
that you want to record is <<hello ' there>>, not <<hello \' there>>.
In other word, the symbol value should not contain the backslash, right?
Does it look like your current implementation will in fact contain it?
> + range_type = create_range_type (NULL,
> + objfile_type (objfile)->builtin_int,
> + 0, strlen(startp));
The indentation is wrong, it should be:
range_type =
create_range_type (NULL,
objfile_type (objfile)->builtin_int,
0, strlen(startp));
> + gdb_test "p /x constchar" " = 0x46" "char constant"
> + gdb_test "p constString1" " = \"String1\"" "String constant 1"
> + gdb_test "p constString2" " = \"String2\"" "String constant 2"
> + gdb_test "p constString3" " = \"String3 with embedded quote ' in
> the middle\"" "String constant 3"
Your last test seems to contradict me on the escape character, but
how does this end up working?
--
Joel
next prev parent reply other threads:[~2010-03-23 18:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-16 21:10 Pierre Muller
2010-03-22 21:56 ` PING " Pierre Muller
2010-03-22 22:19 ` Joel Brobecker
2010-03-23 18:53 ` Joel Brobecker [this message]
2010-03-24 22:55 ` [RFC-v2] " Pierre Muller
2010-04-05 15:19 ` Joel Brobecker
2010-04-05 22:48 ` Pierre Muller
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=20100323185314.GA2882@adacore.com \
--to=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
--cc=pierre.muller@ics-cnrs.unistra.fr \
/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