Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Ingham <jingham@apple.com>
To: gdb-patches@sources.redhat.com
Subject: Trivial bug in valarith.c
Date: Fri, 12 Oct 2001 22:18:00 -0000	[thread overview]
Message-ID: <A470273E-BF99-11D5-AA27-000A277A8808@apple.com> (raw)

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))));
         }

You need to pass the type that has passed through check_typedef (that's 
what type1 is) rather than VALUE_TYPE(arg1) or you might pass a typedef 
to value_from_pointer, which will then issue a scary internal error 
warning.  Here is an example that will show this:

$cat test.c
typedef char * charPtr;

main () {
   charPtr myPtr = (charPtr) "some data";

     printf("Stupid thing to do, huh?\n");

}
$ cc -g -o test test.c
$ gdb test
GNU gdb 5.0-20001113 (Apple version gdb-200) (Mon Sep  3 02:43:52 GMT 
2001) (UI_OUT)
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you 
are
welcome to change it and/or distribute copies of it under certain 
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for 
details.
This GDB was configured as "powerpc-apple-macos10".
Reading symbols for shared libraries .. done
(gdb) break main
Breakpoint 1 at 0x1e80: file test.c, line 4.
(gdb) run
Starting program: /tmp/test
[Switching to thread 1 (process 5994 thread 0x1603)]

Breakpoint 1, main () at test.c:4
4         charPtr myPtr = (charPtr) "some data";
(gdb) n
6           printf("Stupid thing to do, huh?\n");
(gdb) x/4x myPtr-4
gdb-internal-error: findvar.c (store_typed_address): type is not a 
pointer or reference

Jim
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
Jim Ingham                                                           
jingham@apple.com
Developer Tools - gdb


             reply	other threads:[~2001-10-12 22:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-12 22:18 Jim Ingham [this message]
2001-10-13 16:21 ` Andrew Cagney
2001-10-13 18:11   ` Jim Ingham
     [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=A470273E-BF99-11D5-AA27-000A277A8808@apple.com \
    --to=jingham@apple.com \
    --cc=gdb-patches@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