View | Details | Raw Unified | Return to bug 15559 | Differences between
and this patch

Collapse All | Expand All

(-)a/gdb/eval.c (+7 lines)
Lines 45-50 Link Here
45
/* This is defined in valops.c */
45
/* This is defined in valops.c */
46
extern int overload_resolution;
46
extern int overload_resolution;
47
47
48
/* this variable is to notify i386_push_dummy_call that an 
49
  function is static member function, it is a hack */
50
extern int i386_windows_static_memfun;
51
48
/* Prototypes for local functions.  */
52
/* Prototypes for local functions.  */
49
53
50
static struct value *evaluate_subexp_for_sizeof (struct expression *, int *,
54
static struct value *evaluate_subexp_for_sizeof (struct expression *, int *,
Lines 1174-1180 evaluate_funcall (type *expect_type, expression *exp, int *pos, Link Here
1174
	  argvec[1] = argvec[0];
1178
	  argvec[1] = argvec[0];
1175
	  nargs--;
1179
	  nargs--;
1176
	  argvec++;
1180
	  argvec++;
1181
	  i386_windows_static_memfun = 1;
1177
	}
1182
	}
1183
      else
1184
	i386_windows_static_memfun = 0;
1178
    }
1185
    }
1179
  else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
1186
  else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
1180
    {
1187
    {
(-)a/gdb/i386-tdep.c (-2 / +43 lines)
Lines 44-49 Link Here
44
#include "dis-asm.h"
44
#include "dis-asm.h"
45
#include "disasm.h"
45
#include "disasm.h"
46
#include "remote.h"
46
#include "remote.h"
47
#include "utils.h"
48
#include "infcall.h"
47
#include "i386-tdep.h"
49
#include "i386-tdep.h"
48
#include "i387-tdep.h"
50
#include "i387-tdep.h"
49
#include "x86-xstate.h"
51
#include "x86-xstate.h"
Lines 65-70 Link Here
65
#include <ctype.h>
67
#include <ctype.h>
66
#include <algorithm>
68
#include <algorithm>
67
69
70
#include "producer.h"
71
68
/* Register names.  */
72
/* Register names.  */
69
73
70
static const char *i386_register_names[] =
74
static const char *i386_register_names[] =
Lines 2667-2672 i386_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, Link Here
2667
  /* Keep the stack aligned.  */
2671
  /* Keep the stack aligned.  */
2668
  return sp - 16;
2672
  return sp - 16;
2669
}
2673
}
2674
/* This is the hack to handle the non-static member function to thiscall 
2675
   calling convention mode, this variable is updated in eval.c of the 
2676
   static member function check */
2677
int i386_windows_static_memfun = 0; 
2670
2678
2671
static CORE_ADDR
2679
static CORE_ADDR
2672
i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
2680
i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
Lines 2679-2684 i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, Link Here
2679
  int i;
2687
  int i;
2680
  int write_pass;
2688
  int write_pass;
2681
  int args_space = 0;
2689
  int args_space = 0;
2690
  struct type *func_type = value_type (function);
2691
  int i386_windows_thiscall = 0;
2692
  struct compunit_symtab *sym;
2693
  int gcc_minor;
2694
2695
  if (func_type)
2696
    {
2697
      func_type = check_typedef (func_type);
2698
      
2699
      if (TYPE_CODE (func_type) == TYPE_CODE_PTR)
2700
        func_type = check_typedef (TYPE_TARGET_TYPE (func_type));
2701
      
2702
      if( (TYPE_CODE (func_type) == TYPE_CODE_METHOD)
2703
         && (nargs > 0) 
2704
         && i386_windows_static_memfun == 0 )
2705
        {
2706
          sym = find_pc_compunit_symtab(find_function_addr(function,NULL));
2707
          if (sym != NULL && sym->producer != NULL)
2708
          {
2709
            /* if function is build from gcc 4.7 and later, we should use thiscall 
2710
             for non static member function. */
2711
2712
            gcc_minor = producer_is_gcc_ge_4(sym->producer);
2713
            if (gcc_minor > 6)
2714
              i386_windows_thiscall = 1;
2715
          }
2716
        }
2717
    }
2682
2718
2683
  /* BND registers can be in arbitrary values at the moment of the
2719
  /* BND registers can be in arbitrary values at the moment of the
2684
     inferior call.  This can cause boundary violations that are not
2720
     inferior call.  This can cause boundary violations that are not
Lines 2708-2714 i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, Link Here
2708
	    args_space += 4;
2744
	    args_space += 4;
2709
	}
2745
	}
2710
2746
2711
      for (i = 0; i < nargs; i++)
2747
      for (i = i386_windows_thiscall; i < nargs; i++)
2712
	{
2748
	{
2713
	  int len = TYPE_LENGTH (value_enclosing_type (args[i]));
2749
	  int len = TYPE_LENGTH (value_enclosing_type (args[i]));
2714
2750
Lines 2760-2765 i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, Link Here
2760
  /* ...and fake a frame pointer.  */
2796
  /* ...and fake a frame pointer.  */
2761
  regcache->cooked_write (I386_EBP_REGNUM, buf);
2797
  regcache->cooked_write (I386_EBP_REGNUM, buf);
2762
2798
2799
  if (i386_windows_thiscall)
2800
    {
2801
      /* args[0] refer to the last argument which is the this pointer */
2802
      regcache->cooked_write (I386_ECX_REGNUM, value_contents_all(args[0]));
2803
    }
2804
2763
  /* MarkK wrote: This "+ 8" is all over the place:
2805
  /* MarkK wrote: This "+ 8" is all over the place:
2764
     (i386_frame_this_id, i386_sigtramp_frame_this_id,
2806
     (i386_frame_this_id, i386_sigtramp_frame_this_id,
2765
     i386_dummy_id).  It's there, since all frame unwinders for
2807
     i386_dummy_id).  It's there, since all frame unwinders for
2766
- 

Return to bug 15559