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]

Re: Ada gdb failures on hppa


Hi Randolph,

[redirecting to gdb-patches to let others enjoy our discussin too :-)]

> Would you have time to take a look at these ada testcase failures on 
> hppa? I don't know Ada, so I figure you are probably in a better 
> position to understand what's happening :)
> 
> tausq@riot:~/gdb/build/gdb/testsuite$ grep ^FAIL gdb.sum
> FAIL: gdb.ada/array_return.exp: value printed by finish of Create_Large

Just had a minute to have a look at the first issue:

> finish^M
> Run till exit from #0  pck.create_large () at 
> /home/tausq/gdb/gdb-cvs/gdb/testsuite/gdb.ada/array_return/pck.adb:10^M
> p () at 
> /home/tausq/gdb/gdb-cvs/gdb/testsuite/gdb.ada/array_return/p.adb:9^M 9 
>         Small (1) := Large (1);^M
> Value returned has type: . Cannot determine contents^M (gdb) FAIL: 
> gdb.ada/array_return.exp: value printed by finish of Create_Large

It turns out this one is not an Ada-specific issue. The problem is
functions returning structures that are larger than 8 bytes (on hppa)
or 16 bytes (on hppa64). I'm not 100% certain in the hppa64 case, needs
to be double checked, this is just based on code-inspection.

Consider the following C code:

        struct large
        {
          int i;
          int j;
          int k;
          int l;
        };
        
        struct large
        create_large (int i, int j, int k, int l)
        {
          struct large r = {i, j, k, l};
        
          return r;
        }
        
        int
        main (void) 
        {
          struct large l;
        
          l = create_large (1, 3, 7, 13);
          l.i += 1; 
        }

The ABI says in the case of our function returning struct large
that its address should be stored in gr28 by the caller and that
create_large should store the result at the address pointed by
gr28. Just in case, I double-check the code generated by GCC, and
it is conformant.

Here is what happens at the end of the function call:

        static void
        print_return_value (int struct_return, struct type *value_type)
        { 
          [...]
          switch (gdbarch_return_value (gdbarch, value_type, NULL, NULL, NULL))

The return_value method for hppa32 is hppa32_return_value() and it
says:

  if (TYPE_LENGTH (type) <= 2 * 4)
    [...]
  else
    return RETURN_VALUE_STRUCT_CONVENTION;

And then back to print_return_value() this causes us to do this:

    case RETURN_VALUE_STRUCT_CONVENTION:
      value = NULL;
      break;

  [...]
  if (value)
    [...]
  else
    {
      ui_out_text (uiout, "Value returned has type: ");
      ui_out_field_string (uiout, "return-type", TYPE_NAME (value_type));
      ui_out_text (uiout, ".");
      ui_out_text (uiout, " Cannot determine contents\n");
    }     

I wonder what would happen is we changed the STRUCT_CONVENTION into
RETURN_VALUE_ABI_RETURNS_ADDRESS... I'll experiment quickly (have to
run soon) but I have suspicions that messy things might happen :-/.

-- 
Joel



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