This is the mail archive of the gdb-prs@sources.redhat.com 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]

tdep/1388: use_struct_convention -> return_value


>Number:         1388
>Category:       tdep
>Synopsis:       use_struct_convention -> return_value
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          maintenance
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 21 14:48:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     ac131313@redhat.com
>Release:        unknown-1.0
>Organization:
>Environment:

>Description:
GDB currently has four (use_struct_convention, extract_return_value, store_return_value, return_value_on_stack) methods, and half a function (using_struct_return) that know the ABIs return-value conventions.  That leads to 4 1/2 variations of the code needed to determine the location of a return-value.

Recommend a new method:

  int ->return_value (return_type, regcache, inval, outval)

(return_type might be replaced by function type?) that:

- returns non-zero if the return-value is in registers
- stores the return-value INVAL in REGCACHE, if INVAL is non-NULL
- stores the register return-value in OUTVAL, if OUTVAL is non-NULL

This lets the programmer use the coding style:

  if (return_type in registers X:Y:Z)
    {
      if (inval != NULL)
        copy INVAL to REGCACHE X:Y:Z
      if (outval != NULL)
        copy REGCACHE X:Y:Z to OUTVAL
      return 1;
    }
  if (return_type in registers A:B:C)
    ....
  /* Not in a register.  */
  return 0;

There is a tradeoff here - the old model had the "is this in a register?" logic triplicated while the new code has the "read?, write", query?" logic triplicated.  Given that the bugs are invariably in the "in a register?" (the abi spec) eliminating that triplication should make GDB more robust.

Notes:
- The new method should swallow much of set_return_value, and using_struct_return
- There is the potential for many return-value location states: found, not found X on stack, by ref, by register.  This interface only covers: found && by register, not found && by ref.  I can't find code dependant on those additional states.

See the ppc64_sysv_abi_return_value posted to gdb-patches for a full example.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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