This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] wrong pointer type length


Hello,

We've seen a problem that involves stabs on AIX. What we were trying
to do was to print the value of a parameter which is just a pointer
to a structure. GDB prints the value of this pointer as 0x0. The
code comes from our testsuite, and is unfortunately confidential.

We traced down the problem to the fact that the native assembler
seems to be changing up the order in which the stabs entries are
generated. Not sure why. Perhaps Ulrich might know a bit more.
In any case, the assembly file contains the following stabx entries
in that order:

        .stabx "root__union_record_t:Tt42=s12x_part:40,0,32;[...]
        .stabx  "root__union_record_a:t43=*42",0,140,0
        .stabx  "u:p74=k43",808,130,0

However, after being compiled, the order has been changed to:

        1. root__union_record_t:Tt42=s12x_part:40,0,32;[...]
        2. u:p74=k43
        3. root__union_record_a:t43=*42

As a result, when GDB reads in the stabs, it does the following:

  1. Read type 42, and create the associated struct type
  2. Read in parameter 74, finds that it's related to type 43,
     which is not known at this point, and thus uses an undefined
     type for now. Then it makes a const variant of type 43.
  3. Read type 43, finds that it is a pointer to type 42, so
     replaces our undefined type 43 with a pointer to type 42.

The problem is in the creation of the pointer type: We smash the
current type chain, and thus end up not updating the length of
all the variants:

       /* We have storage, but need to reset it.  */
       {
         ntype = *typeptr;
         objfile = TYPE_OBJFILE (ntype);
 -->     smash_type (ntype);
         TYPE_OBJFILE (ntype) = objfile;

The attached patch fixes this.

2007-05-16  Joel Brobecker  <brobecker@adacore.com>

        * gdbtypes.c (make_pointer_type): Preserve the pointer type chain
        and set the length of all the variants of the pointer type.

Tested on x86-linux and ppc-aix, no regressions.  OK to commit?

As a followup to this patch, I think that the same needs to be done
for at least make_reference_type, but I don't have hard evidence that
this will ever be needed right now. If it is agreed that this function
also needs an update, it can be made independently in a followup patch.

I don't think that make_function_type would have a non-empty chain.
So the change shouldn't be needed there. I checked the rest of the
file, and I more or less convinced myself that the code was fine too.

Cheers,
-- 
Joel

Attachment: ptrtype.diff
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]