From: Jim Ingham <jingham@apple.com>
To: Andrew Cagney <ac131313@cygnus.com>
Cc: Jim blandy <jimb@cygnus.com>, gdb-patches@sources.redhat.com
Subject: Re: Trivial bug in valarith.c
Date: Sat, 13 Oct 2001 18:11:00 -0000 [thread overview]
Message-ID: <60FDF2C0-C040-11D5-8605-000A277A8808@apple.com> (raw)
In-Reply-To: <3BC8CC74.4070603@cygnus.com>
Andrew,
> JimB,
>
> While this looks, er obvious, can you give it a quick peek (I think you
> last touched that code ;-). Looks like this problem is also on the 5.1
> branch :-/
cvs tattle points the finger at Jim... He changed value_from_longest -
which presumably doesn't care whether it is handed a pointer or a
typedef, to value_from_pointer which does. That change is correct, you
just have to be careful about the arguments.
Another possible way to fix this, BTW, is to have value_from_pointer
call check_typedef before whinging about the type. Since check_typedef
can sometimes take a bit of work, however, I thought it was better to
keep the contract that you have to pass value_from_pointer a real
pointer, and let the callers do the work - which in most cases they will
have done already anyway.
>
> JimI,
>
> Do you have the ChangeLog entry? Any chance of a testcase?
Oops, forgot the ChangeLog. Here it is:
2001-10-12 Jim Ingham <jingham@inghji.apple.com>
* valarith.c (value_sub): Don't pass a raw type to
value_from_pointer, it has to go through check_typedef first.
If I don't get distracted by some other emergency, I will whip up a
testcase on Monday.
> BTW, I guess:
> (gdb) x/b myPtr+1
> also causes the crash - that is slightly more valid.
Yes, that will cause the problem too. Anything that calls value_sub to
handle a pointer +- integer where the pointer's type is a typedef
instead of a direct pointer will fall over - it doesn't matter how you
format the output.
The original case I was sent was a pointer to some opaque Foundation
type, and I guess x/x made sense in that case, I have no idea. I just
changed the example to something that would not require GnuStep or MacOS
X...
Jim
>
> enjoy,
> Andrew
>
>
>> Hi, all...
>> There's a trivial bug in valarith.c, in value_sub. Here is the patch:
>> Index: valarith.c
>> ===================================================================
>> RCS file: /cvs/src/src/gdb/valarith.c,v
>> retrieving revision 1.9
>> diff -c -w -r1.9 valarith.c
>> *** valarith.c 2001/09/24 17:16:53 1.9
>> --- valarith.c 2001/10/13 05:03:06
>> ***************
>> *** 104,110 ****
>> {
>> /* pointer - integer. */
>> LONGEST sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE
>> (type1)));
>> ! return value_from_pointer (VALUE_TYPE (arg1),
>> (value_as_pointer (arg1)
>> - (sz * value_as_long (arg2))));
>> }
>> --- 104,110 ----
>> {
>> /* pointer - integer. */
>> LONGEST sz = TYPE_LENGTH (check_typedef (TYPE_TARGET_TYPE
>> (type1)));
>> ! return value_from_pointer (type1,
>> (value_as_pointer (arg1)
>> - (sz * value_as_long (arg2))));
>> }
>
>
>
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
Jim Ingham
jingham@apple.com
Developer Tools - gdb
next prev parent reply other threads:[~2001-10-13 18:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-10-12 22:18 Jim Ingham
2001-10-13 16:21 ` Andrew Cagney
2001-10-13 18:11 ` Jim Ingham [this message]
[not found] ` <np8zeca60t.fsf@zwingli.cygnus.com>
2001-10-15 18:15 ` 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=60FDF2C0-C040-11D5-8605-000A277A8808@apple.com \
--to=jingham@apple.com \
--cc=ac131313@cygnus.com \
--cc=gdb-patches@sources.redhat.com \
--cc=jimb@cygnus.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