Sourceware Bugzilla – Attachment 7448 Details for
Bug 15559
Method call and calling convention
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
handling thiscall calling convention for Windows(V3)
i386-windows-thiscall-adjust.patch (text/plain), 3.66 KB, created by
asmwarrior
on 2014-03-01 14:29:10 UTC
(
hide
)
Description:
handling thiscall calling convention for Windows(V3)
Filename:
MIME Type:
Creator:
asmwarrior
Created:
2014-03-01 14:29:10 UTC
Size:
3.66 KB
patch
obsolete
> gdb/eval.c | 7 +++++++ > gdb/i386-tdep.c | 42 +++++++++++++++++++++++++++++++++++++++++- > 2 files changed, 48 insertions(+), 1 deletion(-) > >diff --git a/gdb/eval.c b/gdb/eval.c >index 36615e1..7f835f4 100644 >--- a/gdb/eval.c >+++ b/gdb/eval.c >@@ -48,6 +48,10 @@ > /* This is defined in valops.c */ > extern int overload_resolution; > >+/* this variable is to notify i386_push_dummy_call that an >+ function is static member function, it is a hack */ >+extern int i386_windows_static_memfun; >+ > /* Prototypes for local functions. */ > > static struct value *evaluate_subexp_for_sizeof (struct expression *, int *); >@@ -1667,7 +1671,10 @@ evaluate_subexp_standard (struct type *expect_type, > argvec[1] = argvec[0]; > nargs--; > argvec++; >+ i386_windows_static_memfun = 1; > } >+ else >+ i386_windows_static_memfun = 0; > } > else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR) > { >diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c >index be40b20..9879d61 100644 >--- a/gdb/i386-tdep.c >+++ b/gdb/i386-tdep.c >@@ -45,6 +45,8 @@ > #include "remote.h" > #include "exceptions.h" > #include "gdb_assert.h" >+#include "utils.h" >+#include "infcall.h" > #include <string.h> > > #include "i386-tdep.h" >@@ -2517,6 +2519,10 @@ i386_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, > /* Keep the stack aligned. */ > return sp - 16; > } >+/* This is the hack to handle the non-static member function to thiscall >+ calling convention mode, this variable is updated in eval.c of the >+ static member function check */ >+int i386_windows_static_memfun = 0; > > static CORE_ADDR > i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, >@@ -2529,6 +2535,34 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, > int i; > int write_pass; > int args_space = 0; >+ struct type *func_type = value_type (function); >+ int i386_windows_thiscall = 0; >+ struct symtab *sym; >+ int gcc_minor; >+ >+ if (func_type) >+ { >+ func_type = check_typedef (func_type); >+ >+ if (TYPE_CODE (func_type) == TYPE_CODE_PTR) >+ func_type = check_typedef (TYPE_TARGET_TYPE (func_type)); >+ >+ if( (TYPE_CODE (func_type) == TYPE_CODE_METHOD) >+ && (nargs > 0) >+ && i386_windows_static_memfun == 0 ) >+ { >+ sym = find_pc_symtab(find_function_addr(function,NULL)); >+ if (sym != NULL && sym->producer != NULL) >+ { >+ /* if function is build from gcc 4.7 and later, we should use thiscall >+ for non static member function. */ >+ >+ gcc_minor = producer_is_gcc_ge_4(sym->producer); >+ if (gcc_minor > 6) >+ i386_windows_thiscall = 1; >+ } >+ } >+ } > > /* Determine the total space required for arguments and struct > return address in a first pass (allowing for 16-byte-aligned >@@ -2551,7 +2585,7 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, > args_space += 4; > } > >- for (i = 0; i < nargs; i++) >+ for (i = i386_windows_thiscall; i < nargs; i++) > { > int len = TYPE_LENGTH (value_enclosing_type (args[i])); > >@@ -2603,6 +2637,12 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, > /* ...and fake a frame pointer. */ > regcache_cooked_write (regcache, I386_EBP_REGNUM, buf); > >+ if (i386_windows_thiscall) >+ { >+ /* args[0] refer to the last argument which is the this pointer */ >+ regcache_cooked_write (regcache, I386_ECX_REGNUM, value_contents_all(args[0])); >+ } >+ > /* MarkK wrote: This "+ 8" is all over the place: > (i386_frame_this_id, i386_sigtramp_frame_this_id, > i386_dummy_id). It's there, since all frame unwinders for
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 15559
:
7225
|
7227
|
7438
|
7443
| 7448 |
11182