Sourceware Bugzilla – Attachment 7443 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]
[patch]
use thiscall calling convention for class members (try 2)
0001-use-thiscall-calling-convention-for-class-members.patch (text/plain), 3.55 KB, created by
Hannes Domani
on 2014-02-26 20:24:17 UTC
(
hide
)
Description:
use thiscall calling convention for class members (try 2)
Filename:
MIME Type:
Creator:
Hannes Domani
Created:
2014-02-26 20:24:17 UTC
Size:
3.55 KB
patch
obsolete
>From bf6a181c82a906349367d635b775c3fd8fab05b0 Mon Sep 17 00:00:00 2001 >From: Hannes Domani <ssbssa@yahoo.de> >Date: Wed, 26 Feb 2014 21:16:59 +0100 >Subject: [PATCH] use thiscall calling convention for class members > >--- > gdb/i386-tdep.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 73 insertions(+), 1 deletion(-) > >diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c >index bb414b6..a5150f1 100644 >--- a/gdb/i386-tdep.c >+++ b/gdb/i386-tdep.c >@@ -45,6 +45,7 @@ > #include "remote.h" > #include "exceptions.h" > #include "gdb_assert.h" >+#include "infcall.h" > #include <string.h> > > #include "i386-tdep.h" >@@ -2529,6 +2530,72 @@ 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; >+ >+ 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) >+ { >+ CORE_ADDR funaddr = find_function_addr (function, NULL); >+ struct symbol *funsym = find_pc_function (funaddr); >+ if (funsym != NULL >+ && SYMBOL_BLOCK_OPS (funsym)) >+ { >+ struct symbol *thissym; >+ thissym = lookup_block_symbol (funsym->ginfo.value.block, >+ "this", VAR_DOMAIN); >+ if (thissym != NULL >+ && SYMBOL_COMPUTED_OPS (thissym) >+ && SYMBOL_COMPUTED_OPS (thissym)->tracepoint_var_ref) >+ { >+ struct axs_value av; >+ struct agent_expr *ax = >+ new_agent_expr (gdbarch, funaddr); >+ volatile struct gdb_exception ex; >+ >+ av.type = check_typedef (SYMBOL_TYPE (thissym)); >+ av.optimized_out = 0; >+ >+ TRY_CATCH (ex, RETURN_MASK_ERROR) >+ { >+ SYMBOL_COMPUTED_OPS (thissym)-> >+ tracepoint_var_ref (thissym, gdbarch, ax, &av); >+ } >+ if (ex.reason >= 0) >+ { >+ unsigned char espLoc[] = { >+ aop_reg, 0, I386_ESP_REGNUM, >+ aop_const8, 4, >+ aop_add, >+ aop_const8, 0xf4, >+ aop_ext, 8, >+ aop_add, >+ }; >+ if (av.kind == axs_lvalue_register >+ && av.u.reg == I386_ECX_REGNUM) >+ /* 'this' pointer is stored in register ECX. */ >+ i386_windows_thiscall = 1; >+ else if (av.kind == axs_lvalue_memory >+ && ax->len == sizeof (espLoc) >+ && !memcmp (ax->buf, espLoc, sizeof (espLoc))) >+ /* 'this' pointer is copied from ECX to >+ stack-relative -12 (0xf4), happens when >+ comiled with -O0. */ >+ i386_windows_thiscall = 1; >+ } >+ >+ free_agent_expr (ax); >+ } >+ } >+ } >+ } > > /* Determine the total space required for arguments and struct > return address in a first pass (allowing for 16-byte-aligned >@@ -2551,7 +2618,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 +2670,11 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, > /* ...and fake a frame pointer. */ > regcache_cooked_write (regcache, I386_EBP_REGNUM, buf); > >+ /* 'this' pointer needs to be in ECX. */ >+ if (i386_windows_thiscall) >+ 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 >-- >1.8.4.msysgit.0 >
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 Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 15559
:
7225
|
7227
|
7438
| 7443 |
7448
|
11182