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] Support for multiple calling conventions, patch 1/3: Add calling convention to struct type


Hi,

this is the first of three patches which enable to use calling convention
information in the dwarf2 information in GDB.  The general problem has
been discussed in http://sources.redhat.com/ml/gdb/2008-04/msg00090.html

The first patch (this one) just enables the basic use of the dawrf2
calling convention.

The second patch is a pure mechanical patch which adds the function type
information to calls of gdbarch_return_value.

The third patch enables to use the calling convention information
specifically for the sh target.

Ok, now the first patch.  It just adds the calling_convention member to
struct type and fills it in dwarf2read.c:read_subroutine_type so that
all function types have a calling convention information if the debug
information is given as dwarf2.

The result looks like this:

  ftype->calling_convention == 0
  
    if no debug information is available for the function or if the
    debug information is not given as dwarf2.

  ftype->calling_convention == DW_CC_normal
  
    if dwarf2 debug information is available for the function but no
    DW_AT_calling_convention attribute has been given for the function.

  ftype->calling_convention == DW_UNSND(DW_AT_calling_convention)

    if dwarf2 debug information is available for the function and the
    DW_AT_calling_convention attribute has been specified.

If the calling convention can be retrieved by other means, this could
now be added easily.


Ok to apply?

Thanks,
Corinna


        * gdbtypes.h (struct type): Add calling_convention member.
        * dwarf2read.c (read_subroutine_type): Add calling convention read
        from DW_AT_calling_convention attribute to function type.


Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.254
diff -u -p -r1.254 dwarf2read.c
--- dwarf2read.c	26 Mar 2008 14:53:28 -0000	1.254
+++ dwarf2read.c	15 Apr 2008 10:41:36 -0000
@@ -4889,6 +4889,12 @@ read_subroutine_type (struct die_info *d
       || cu->language == language_pascal)
     TYPE_FLAGS (ftype) |= TYPE_FLAG_PROTOTYPED;
 
+  /* Store the calling convention in the type if it's available in
+     the subroutine die.  Otherwise set the calling convention to
+     the default value DW_CC_normal.  */
+  attr = dwarf2_attr (die, DW_AT_calling_convention, cu);
+  ftype->calling_convention = attr ? DW_UNSND (attr) : DW_CC_normal;
+  
   if (die->child != NULL)
     {
       struct die_info *child_die;
Index: gdbtypes.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbtypes.h,v
retrieving revision 1.85
diff -u -p -r1.85 gdbtypes.h
--- gdbtypes.h	3 Feb 2008 22:13:29 -0000	1.85
+++ gdbtypes.h	15 Apr 2008 10:41:37 -0000
@@ -510,6 +510,11 @@ struct type
      on the ring we are.  */
   int instance_flags;
 
+  /* For function types, the calling convention for targets supporting
+     multiple ABIs.  Right now this is only fetched from the Dwarf-2
+     DW_AT_calling_convention attribute.  */
+  unsigned calling_convention;
+
   /* Length of storage for a value of this type.  This is what
      sizeof(type) would return; use it for address arithmetic,
      memory reads and writes, etc.  This size includes padding.  For
@@ -759,6 +764,7 @@ extern void allocate_cplus_struct_type (
   (TYPE_CPLUS_SPECIFIC(type) != &cplus_struct_default)
 
 #define TYPE_INSTANCE_FLAGS(thistype) (thistype)->instance_flags
+#define TYPE_CALLING_CONVENTION(thistype) (thistype)->calling_convention
 #define TYPE_MAIN_TYPE(thistype) (thistype)->main_type
 #define TYPE_NAME(thistype) TYPE_MAIN_TYPE(thistype)->name
 #define TYPE_TAG_NAME(type) TYPE_MAIN_TYPE(type)->tag_name


-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


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