From: Tom Tromey <tromey@redhat.com>
To: Joel Brobecker <brobecker@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [RFA] ax-gdb: Do not treat enums and bools as integers.
Date: Fri, 09 Mar 2012 17:00:00 -0000 [thread overview]
Message-ID: <874ntxlng9.fsf@fleche.redhat.com> (raw)
In-Reply-To: <1331240440-13559-1-git-send-email-brobecker@adacore.com> (Joel Brobecker's message of "Thu, 8 Mar 2012 13:00:40 -0800")
>>>>> "Joel" == Joel Brobecker <brobecker@adacore.com> writes:
Joel> But the reason why GDB decides to use a 32bit extension is because
Joel> it overrides the symbol's type with a plain integer type in
Joel> ax-gdb.c:gen_usual_unary...
FWIW you can see the bug from C, if you make an enum type and then
compile with -fshort-enums (which IIRC is the default for some targets).
Then:
(gdb) maintenance agent-eval e
Scope: 0x400478
Reg mask: 00
0 const32 6293576
5 ref8
6 end
Here the 'ref8' is correct -- 'e' is a 1-byte variable.
But:
(gdb) maintenance agent-eval e + 1
Scope: 0x400478
Reg mask: 00
0 const32 6293576
5 ref32
6 ext 32
8 const8 1
10 add
11 ext 32
13 end
Whoops, how did that ref32 get there?
Joel> * ax-gdb.c (gen_usual_unary): Remove special handling of
Joel> enum and bool types.
I think it is correct.
Also, I think you can make a test case like this:
enum EE {
VALUE = 1
};
struct x {
unsigned char before;
enum EE e;
unsigned char after;
};
struct x global;
int main () { }
Compile with -fshort-enums.
Then:
(gdb) maint agent-eval global.e + 1
Scope: 0x400478
Reg mask: 00
0 const32 6293576
5 const8 1
7 add
8 ref32
9 ext 32
11 const8 1
13 add
14 ext 32
16 end
So, I think you could provoke the wrong answer by setting 'after' to
some non-zero value.
Tom
next prev parent reply other threads:[~2012-03-09 17:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-08 21:01 Joel Brobecker
2012-03-08 23:00 ` Joel Brobecker
2012-03-09 17:00 ` Tom Tromey [this message]
2012-03-14 1:43 ` Joel Brobecker
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=874ntxlng9.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=brobecker@adacore.com \
--cc=gdb-patches@sourceware.org \
/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