From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: Tom Tromey <tromey@redhat.com>
Cc: Yao Qi <yao@codesourcery.com>, gdb-patches@sourceware.org
Subject: Re: RFC: fix `gdb -write' case
Date: Wed, 11 May 2011 14:38:00 -0000 [thread overview]
Message-ID: <20110511143828.GA28962@host1.jankratochvil.net> (raw)
In-Reply-To: <m3wri0sz65.fsf@fleche.redhat.com>
>>>>> "Yao" == Yao Qi <yao@codesourcery.com> writes:
Tom> https://bugzilla.redhat.com/show_bug.cgi?id=696148
Yao> FYI, I can't access this bug. I am told "You are not authorized to
Yao> access bug #696148."
In that Bug I made a comment
# evaluate_subexp_c->OP_STRING ignores expect_type, GDB then tries to convert
# the non-matching type using malloc.
which I advocate below.
On Mon, 09 May 2011 16:53:38 +0200, Tom Tromey wrote:
> Yao> Any difference on these two type variables (expect_type vs. stringtype)?
>
> Yes. You can wind up with a different "char" type following the logic
> in c-lang.c. In this case some higher level will try to cast the string
> to the correct type, which will try to force it to memory, leading to
> the bad result.
>
> The checks in the patch are intended to ensure that the expected type
> isn't "too weird" -- that we don't do something nonsensical.
The approach you took is not in the style of current GDB:
#include <wchar.h>
short a_short[2];
long a_long[2];
char a_char[3];
wchar_t a_wchar[3];
int main (void) { return 0; }
# With gcc only - without libstdc++ linked - GDB complains despite the code
# compiled and runs fine; but that is a different Bug.
# (gdb) p U"x"
# No type named char32_t.
g++ -g
(gdb) start
(gdb) set a_short={1L,2LL}
(gdb) p a_short
$1 = {1, 2}
(gdb) ptype a_short
type = short [2]
(gdb) set a_long={1L,2LL}
(gdb) p a_long
$2 = {1, 2}
(gdb) ptype a_long
type = long [2]
(gdb) set a_char=U"x"
expected type of string constant has wrong character width
(gdb) set a_wchar="x"
expected type of string constant has wrong character width
(gdb)
I believe if GDB adjusts the short/long types shouldn't it adjust also
char/whar_t types? That is now the user must know the type of string in
advance which wasn't the case for arrays before.
But it is not a real regression as GDB had not supported Unicode strings.
This is why I made the comment above.
Thanks,
Jan
next prev parent reply other threads:[~2011-05-11 14:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-06 17:12 Tom Tromey
2011-05-09 3:11 ` Yao Qi
2011-05-09 14:54 ` Tom Tromey
2011-05-10 2:03 ` Yao Qi
2011-05-10 14:16 ` Tom Tromey
2011-05-11 8:06 ` Jan Kratochvil
2011-05-11 14:38 ` Jan Kratochvil [this message]
2011-05-11 19:42 ` Tom Tromey
2011-05-22 18:24 ` Jan Kratochvil
2011-05-23 20:24 ` Tom Tromey
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=20110511143828.GA28962@host1.jankratochvil.net \
--to=jan.kratochvil@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=tromey@redhat.com \
--cc=yao@codesourcery.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