diff options
author | Hannes Domani <ssbssa@yahoo.de> | 2020-04-27 15:58:09 +0200 |
---|---|---|
committer | Hannes Domani <ssbssa@yahoo.de> | 2020-04-30 14:36:55 +0200 |
commit | 627c7fb8ea16388f349b6b26e20bf017d71e51fe (patch) | |
tree | 6c3768b72f7861c80244e1cc16c1bebf88c76e7c /gdb/i386-windows-tdep.c | |
parent | c578f16ef18fde35d5887909d5faaf0bd0118e9d (diff) | |
download | binutils-gdb-627c7fb8ea16388f349b6b26e20bf017d71e51fe.tar.gz |
Use thiscall calling convention for class members
Non-static member functions for Windows 32bit programs need the thiscall
calling convention, so the 'this' pointer needs to be passed in ECX.
gdb/ChangeLog:
2020-04-30 Hannes Domani <ssbssa@yahoo.de>
PR gdb/15559
* i386-tdep.c (i386_push_dummy_call): Call
i386_thiscall_push_dummy_call.
(i386_thiscall_push_dummy_call): New function.
* i386-tdep.h (i386_thiscall_push_dummy_call): Declare.
* i386-windows-tdep.c (i386_windows_push_dummy_call): New function.
(i386_windows_init_abi): Call set_gdbarch_push_dummy_call.
Diffstat (limited to 'gdb/i386-windows-tdep.c')
-rw-r--r-- | gdb/i386-windows-tdep.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gdb/i386-windows-tdep.c b/gdb/i386-windows-tdep.c index 3a07c862f23..4824a9e5528 100644 --- a/gdb/i386-windows-tdep.c +++ b/gdb/i386-windows-tdep.c @@ -200,6 +200,36 @@ i386_windows_auto_wide_charset (void) return "UTF-16"; } +/* Implement the "push_dummy_call" gdbarch method. */ + +static CORE_ADDR +i386_windows_push_dummy_call (struct gdbarch *gdbarch, struct value *function, + struct regcache *regcache, CORE_ADDR bp_addr, + int nargs, struct value **args, CORE_ADDR sp, + function_call_return_method return_method, + CORE_ADDR struct_addr) +{ + /* For non-static member functions of 32bit Windows programs, the thiscall + calling convention is used, so the 'this' pointer is passed in ECX. */ + bool thiscall = false; + + struct type *type = check_typedef (value_type (function)); + if (TYPE_CODE (type) == TYPE_CODE_PTR) + type = check_typedef (TYPE_TARGET_TYPE (type)); + + /* read_subroutine_type sets for non-static member functions the + artificial flag of the first parameter ('this' pointer). */ + if (TYPE_CODE (type) == TYPE_CODE_METHOD + && TYPE_NFIELDS (type) > 0 + && TYPE_FIELD_ARTIFICIAL (type, 0) + && TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_PTR) + thiscall = 1; + + return i386_thiscall_push_dummy_call (gdbarch, function, regcache, bp_addr, + nargs, args, sp, return_method, + struct_addr, thiscall); +} + /* Common parts for gdbarch initialization for Windows and Cygwin on i386. */ static void @@ -234,6 +264,8 @@ i386_windows_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { i386_windows_init_abi_common (info, gdbarch); windows_init_abi (info, gdbarch); + + set_gdbarch_push_dummy_call (gdbarch, i386_windows_push_dummy_call); } /* gdbarch initialization for Cygwin on i386. */ |