[patch] Set calling convention of methods

Jonas Maebe
2009-04-06T19:51:21Z

[-- Attachment #1: Type: text/plain, Size: 1360 bytes --]

Hello,

In attachment is my patch to set the calling convention for methods.
Since the calling convention cannot be defined using stabs, I've
hardcoded "0" there (which means that nothing changes compared to the
past). Maybe that should rather be some constant? If so, where should
it be defined?

The patch is against the "archer" branch of Archer (not the master
branch as I wrote earlier), but it applies cleanly against CVS head
with only a bit of fuzz (and compiles). I have tested it in Archer in
combination with an improved version of my Borland fastcall patch
(which Mark Kettenis kindly offered to review) and some small changes
in p-exp.y, and can successfully call both regular and virtual Free
Pascal methods with it that use the Borland fastcall calling convention.

Thanks,

Jonas

2009-04-06 Jonas Maebe <jonas.maebe@elis.ugent.be>

Set the type.type_specific.calling_convention field for methods.

* gdbtypes.h (smash_to_method_type): Add calling_convention parameter.
* gdbtypes.c (smash_to_method_type): Set method calling convention
based
on calling_convention parameter.
* dwarf2read.c (dwarf2_add_member_fn): Pass calling convention to
smash_to_method_type().
(quirk_gcc_member_function_pointer): Likewise.
* stabsread.c (read_type): Pass 0 (== default) as calling convention to
smash_to_method_type().

[-- Attachment #2: gdb_method_calling_conventions.patch --]
[-- Type: application/octet-stream, Size: 2662 bytes --]

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 625c416..59a6f0e 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4426,7 +4426,8 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
TYPE_TARGET_TYPE (this_type),
TYPE_FIELDS (this_type),
TYPE_NFIELDS (this_type),
- TYPE_VARARGS (this_type));
+ TYPE_VARARGS (this_type),
+ TYPE_CALLING_CONVENTION (this_type));

/* Handle static member functions.
Dwarf2 has no clean way to discern C++ static and non-static
@@ -4601,7 +4602,8 @@ quirk_gcc_member_function_pointer (struct die_info *die, struct dwarf2_cu *cu)
type = alloc_type (objfile, NULL);
smash_to_method_type (type, domain_type, TYPE_TARGET_TYPE (pfn_type),
TYPE_FIELDS (pfn_type), TYPE_NFIELDS (pfn_type),
- TYPE_VARARGS (pfn_type));
+ TYPE_VARARGS (pfn_type),
+ TYPE_CALLING_CONVENTION (pfn_type));
type = lookup_methodptr_type (type);
return set_die_type (die, type, cu);
}
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 012485c..858d7ca 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1074,7 +1074,7 @@ smash_to_memberptr_type (struct type *type, struct type *domain,
void
smash_to_method_type (struct type *type, struct type *domain,
struct type *to_type, struct field *args,
- int nargs, int varargs)
+ int nargs, int varargs, unsigned calling_convention)
{
struct objfile *objfile;

@@ -1088,6 +1088,7 @@ smash_to_method_type (struct type *type, struct type *domain,
TYPE_NFIELDS (type) = nargs;
if (varargs)
TYPE_VARARGS (type) = 1;
+ TYPE_CALLING_CONVENTION (type) = calling_convention;
TYPE_LENGTH (type) = 1; /* In practice, this is never needed. */
TYPE_CODE (type) = TYPE_CODE_METHOD;
}
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 9ce920b..ddf4e7b 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1235,7 +1235,8 @@ extern struct type *lookup_methodptr_type (struct type *);

extern void smash_to_method_type (struct type *type, struct type *domain,
struct type *to_type, struct field *args,
- int nargs, int varargs);
+ int nargs, int varargs,
+ unsigned calling_convention);

extern void smash_to_memberptr_type (struct type *, struct type *,
struct type *);
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 3b8eb29..02fac7e 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -1868,7 +1868,7 @@ again:
return error_type (pp, objfile);
type = dbx_alloc_type (typenums, objfile);
smash_to_method_type (type, domain, return_type, args,
- nargs, varargs);
+ nargs, varargs, 0);
}
break;

[-- Attachment #3: Type: text/plain, Size: 1 bytes --]