public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* Support for multiple sized pointers in a program
@ 2003-04-01 23:37 CUTHBERTSON,REVA (HP-Cupertino,ex3)
  2003-04-01 23:44 ` Kevin Buettner
  0 siblings, 1 reply; 2+ messages in thread
From: CUTHBERTSON,REVA (HP-Cupertino,ex3) @ 2003-04-01 23:37 UTC (permalink / raw)
  To: 'gdb@sources.redhat.com'

Hello,

I am porting gdb to a platform which allows both 32-bit and 64-bit pointers
to coexist in a program.  I am running into a problem creating pointer types
when 2 different sized pointers point to the same target type in the same
program.  

The problem seems to be in make_pointer_type() in gdbtypes.c.  The function
creates a pointer type for the target type if one does not exist, fills in
the length of the pointer, fills in the flags and returns the pointer type.
What it also does is save the new pointer type into the "pointer_type" field
of the target type.  The next time I call this function for the same target
type, it will return the pointer type I just made even if the next pointer
to the target type is a different size.  This will be a problem when you try
to fetch the value of a pointer, etc.

The problem appears to be the 1-1 mapping between the pointer type and the
target type.  I made a change in make_pointer_type()  which disables the
code that saves the pointer type in the "pointer_type" field of the target
type.  I simply return the pointer type which ultimately gets attached to a
symbol.  With this change, I'm able to print out pointers of different sizes
even when they point to the same thing.  What I don't understand is why
there is the 1-1 mapping in the first place between a type and a pointer
type.  I see code all over gdb which calls lookup_pointer_type() on a type
-- such as builtin_type_void and builtin_type_char.   What is the purpose
for looking up the pointer type of a type that is not associated with a
symbol?  I'm concerned that my change will have consequences on code that
calls lookup_pointer_type() in this way.  Is my fix correct or should I be
doing something a different way?

Any help on this would be greatly appreciated!!!!

Reva Cuthbertson
reva_cuthbertson@hp.com


  

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Support for multiple sized pointers in a program
  2003-04-01 23:37 Support for multiple sized pointers in a program CUTHBERTSON,REVA (HP-Cupertino,ex3)
@ 2003-04-01 23:44 ` Kevin Buettner
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Buettner @ 2003-04-01 23:44 UTC (permalink / raw)
  To: CUTHBERTSON,REVA (HP-Cupertino,ex3), 'gdb@sources.redhat.com'

On Apr 1,  3:37pm, CUTHBERTSON,REVA (HP-Cupertino,ex3) wrote:

> I am porting gdb to a platform which allows both 32-bit and 64-bit pointers
> to coexist in a program.  I am running into a problem creating pointer types
> when 2 different sized pointers point to the same target type in the same
> program.  
> 
> The problem seems to be in make_pointer_type() in gdbtypes.c.  The function
> creates a pointer type for the target type if one does not exist, fills in
> the length of the pointer, fills in the flags and returns the pointer type.
> What it also does is save the new pointer type into the "pointer_type" field
> of the target type.  The next time I call this function for the same target
> type, it will return the pointer type I just made even if the next pointer
> to the target type is a different size.  This will be a problem when you try
> to fetch the value of a pointer, etc.
> 
> The problem appears to be the 1-1 mapping between the pointer type and the
> target type.  I made a change in make_pointer_type()  which disables the
> code that saves the pointer type in the "pointer_type" field of the target
> type.  I simply return the pointer type which ultimately gets attached to a
> symbol.  With this change, I'm able to print out pointers of different sizes
> even when they point to the same thing.  What I don't understand is why
> there is the 1-1 mapping in the first place between a type and a pointer
> type.  I see code all over gdb which calls lookup_pointer_type() on a type
> -- such as builtin_type_void and builtin_type_char.   What is the purpose
> for looking up the pointer type of a type that is not associated with a
> symbol?  I'm concerned that my change will have consequences on code that
> calls lookup_pointer_type() in this way.  Is my fix correct or should I be
> doing something a different way?
> 
> Any help on this would be greatly appreciated!!!!

Take a look at the "address class" support that I added last year.  I
needed it to handle this precise problem.  (Grep the gdb sources for
ADDRESS_CLASS.)

Kevin

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-04-01 23:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-01 23:37 Support for multiple sized pointers in a program CUTHBERTSON,REVA (HP-Cupertino,ex3)
2003-04-01 23:44 ` Kevin Buettner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).