Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@zwingli.cygnus.com>
To: Andrew Cagney <ac131313@cygnus.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: RFA: fix GDB casts when pointers are not addresses
Date: Thu, 05 Jul 2001 16:23:00 -0000	[thread overview]
Message-ID: <npbsmzm01n.fsf@zwingli.cygnus.com> (raw)
In-Reply-To: <3B44C964.6050805@cygnus.com>

Andrew Cagney <ac131313@cygnus.com> writes:
> > Sure.
> > 
> > $ cat pointer2.c
> > #include <stdio.h>
> > 
> > main ()
> > {
> >   printf ("0x%x\n", (int) &main);
> > }
> > $ $CMitsuB/d10v-elf-gcc -g pointer2.c -o pointer2
> > $ $CMitsuB/d10v-elf-run pointer2
> > 0x5017
> > $ $DD10v/gdb/gdb pointer2
> > GNU gdb 2001-07-02-cvs (MI_OUT)
> > Copyright 2001 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 "--host=i686-pc-linux-gnu --target=d10v-elf"...
> > (gdb) print (int) &main
> > $1 = 16476
> > (gdb) p/x (int) &main
> > $2 = 0x405c
> 
> 
> Is this before or after all the changes?  My understanding of what you 
> were proposing was that it would output the same as for GCC vis:
> 
> $2 = 0x5017

The above is the behavior after applying only:
- "RFA: Add builtin void (*) () type"
- "RFA: Revised: Remove D10V-specific code from arch-independent modules"

If I instead apply:
- "RFA: Add builtin void (*) () type"
- "RFA: Revised: Remove D10V-specific code from arch-independent modules"
- "RFA: fix GDB casts when pointers are not addresses"

Then I get this behavior: 

zenia:play$ $DD10v/gdb/gdb pointer2
GNU gdb 2001-07-05-cvs (MI_OUT)
Copyright 2001 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 "--host=i686-pc-linux-gnu --target=d10v-elf"...
(gdb) print (int) &main
$1 = 20503
(gdb) p/x (int) &main
$2 = 0x5017
(gdb) 

Here, the expression yields the same result in GDB as it does under
GCC.

> > Sure.  The patch includes a comment which is supposed to set this
> > straight.  What is it missing?
> 
> I was thinking more of doc/gdb.texinfo.

Something like this?

Index: gdb.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
retrieving revision 1.38
diff -c -c -b -F'^(' -r1.38 gdb.texinfo
*** gdb.texinfo	2001/04/02 08:58:19	1.38
--- gdb.texinfo	2001/07/05 23:23:31
***************
*** 4381,4387 ****
  
  Casts are supported in all languages, not just in C, because it is so
  useful to cast a number into a pointer in order to examine a structure
! at that address in memory.
  @c FIXME: casts supported---Mod2 true?
  
  @value{GDBN} supports these operators, in addition to those common
--- 4381,4388 ----
  
  Casts are supported in all languages, not just in C, because it is so
  useful to cast a number into a pointer in order to examine a structure
! at that address in memory.  Where the value of a cast is undefined by
! the language, GDB tries to interpret the cast the same way GCC would.
  @c FIXME: casts supported---Mod2 true?
  
  @value{GDBN} supports these operators, in addition to those common


  reply	other threads:[~2001-07-05 16:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20010628225704.9AB635E9CB@zwingli.cygnus.com>
2001-07-04 22:15 ` Andrew Cagney
2001-07-05 11:48   ` Jim Blandy
2001-07-05 13:09     ` Andrew Cagney
2001-07-05 16:23       ` Jim Blandy [this message]
2001-07-05 23:08         ` Andrew Cagney
2001-07-06 16:28           ` Jim Blandy
2001-07-10 13:33             ` Andrew Cagney
2001-07-05 23:12   ` Andrew Cagney
2001-07-09 19:55 David Taylor

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=npbsmzm01n.fsf@zwingli.cygnus.com \
    --to=jimb@zwingli.cygnus.com \
    --cc=ac131313@cygnus.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