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

Collapse All | Expand All

(-)a/gdb/eval.c (+7 lines)
Lines 49-54 Link Here
49
/* This is defined in valops.c */
49
/* This is defined in valops.c */
50
extern int overload_resolution;
50
extern int overload_resolution;
51
51
52
/* this variable is to notify i386_push_dummy_call that an 
53
  function is static member function, it is a hack */
54
extern int i386_windows_static_memfun; 
55
52
/* Prototypes for local functions.  */
56
/* Prototypes for local functions.  */
53
57
54
static struct value *evaluate_subexp_for_sizeof (struct expression *, int *);
58
static struct value *evaluate_subexp_for_sizeof (struct expression *, int *);
Lines 1668-1674 evaluate_subexp_standard (struct type *expect_type, Link Here
1668
	      argvec[1] = argvec[0];
1672
	      argvec[1] = argvec[0];
1669
	      nargs--;
1673
	      nargs--;
1670
	      argvec++;
1674
	      argvec++;
1675
	      i386_windows_static_memfun = 1;
1671
	    }
1676
	    }
1677
          else
1678
            i386_windows_static_memfun = 0;
1672
	}
1679
	}
1673
      else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
1680
      else if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
1674
	{
1681
	{
(-)a/gdb/i386-tdep.c (-1 / +38 lines)
Lines 2396-2401 i386_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr, Link Here
2396
  /* Keep the stack aligned.  */
2396
  /* Keep the stack aligned.  */
2397
  return sp - 16;
2397
  return sp - 16;
2398
}
2398
}
2399
/* This is the hack to handle the non-static member function to thiscall 
2400
   calling convention mode, this variable is updated in eval.c of the 
2401
   static member function check */
2402
int i386_windows_static_memfun = 0; 
2403
2404
/* This is the hack to determine which version of gcc is used to generate
2405
   the function, if it is greater than 4.6, this use thiscall for member
2406
   function. */
2407
int i386_windows_build_gt_gcc46 = 0;
2399
2408
2400
static CORE_ADDR
2409
static CORE_ADDR
2401
i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
2410
i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
Lines 2408-2413 i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, Link Here
2408
  int i;
2417
  int i;
2409
  int write_pass;
2418
  int write_pass;
2410
  int args_space = 0;
2419
  int args_space = 0;
2420
  struct type *func_type = value_type (function);
2421
  int i386_windows_thiscall = 0;
2422
2423
  if (func_type)
2424
    {
2425
      func_type = check_typedef (func_type);
2426
      
2427
      if (TYPE_CODE (func_type) == TYPE_CODE_PTR)
2428
        func_type = check_typedef (TYPE_TARGET_TYPE (func_type));
2429
      
2430
      if( (TYPE_CODE (func_type) == TYPE_CODE_METHOD)
2431
         && i386_windows_build_gt_gcc46 == 1
2432
         && (nargs > 0) 
2433
         && i386_windows_static_memfun == 0 )
2434
        {
2435
         /* a.f(5,6);
2436
            args[0] = this pointer;
2437
            args[1] = 5;
2438
            args[2] = 6; */
2439
         i386_windows_thiscall = 1;
2440
        }
2441
    }
2411
2442
2412
  /* Determine the total space required for arguments and struct
2443
  /* Determine the total space required for arguments and struct
2413
     return address in a first pass (allowing for 16-byte-aligned
2444
     return address in a first pass (allowing for 16-byte-aligned
Lines 2430-2436 i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, Link Here
2430
	    args_space += 4;
2461
	    args_space += 4;
2431
	}
2462
	}
2432
2463
2433
      for (i = 0; i < nargs; i++)
2464
      for (i = i386_windows_thiscall; i < nargs; i++)
2434
	{
2465
	{
2435
	  int len = TYPE_LENGTH (value_enclosing_type (args[i]));
2466
	  int len = TYPE_LENGTH (value_enclosing_type (args[i]));
2436
2467
Lines 2482-2487 i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, Link Here
2482
  /* ...and fake a frame pointer.  */
2513
  /* ...and fake a frame pointer.  */
2483
  regcache_cooked_write (regcache, I386_EBP_REGNUM, buf);
2514
  regcache_cooked_write (regcache, I386_EBP_REGNUM, buf);
2484
2515
2516
  if (i386_windows_thiscall)
2517
    {
2518
      /* args[0] refer to the last argument which is the this pointer */
2519
      regcache_cooked_write (regcache, I386_ECX_REGNUM, value_contents_all(args[0]));
2520
    }
2521
2485
  /* MarkK wrote: This "+ 8" is all over the place:
2522
  /* MarkK wrote: This "+ 8" is all over the place:
2486
     (i386_frame_this_id, i386_sigtramp_frame_this_id,
2523
     (i386_frame_this_id, i386_sigtramp_frame_this_id,
2487
     i386_dummy_id).  It's there, since all frame unwinders for
2524
     i386_dummy_id).  It's there, since all frame unwinders for
(-)a/gdb/infcall.c (+23 lines)
Lines 36-41 Link Here
36
#include "ada-lang.h"
36
#include "ada-lang.h"
37
#include "gdbthread.h"
37
#include "gdbthread.h"
38
#include "exceptions.h"
38
#include "exceptions.h"
39
#include "utils.h"
40
41
/* this value is defined in i386-tdep.c, and we set this value here
42
   if the dummy call function is build from gcc 4.7 and later, we 
43
   should set this value to 1, other wise, set it to 0 */
44
extern int i386_windows_build_gt_gcc46;
39
45
40
/* If we can't find a function's name from its address,
46
/* If we can't find a function's name from its address,
41
   we print this instead.  */
47
   we print this instead.  */
Lines 480-485 call_function_by_hand (struct value *function, int nargs, struct value **args) Link Here
480
  ptid_t call_thread_ptid;
486
  ptid_t call_thread_ptid;
481
  struct gdb_exception e;
487
  struct gdb_exception e;
482
  char name_buf[RAW_FUNCTION_ADDRESS_SIZE];
488
  char name_buf[RAW_FUNCTION_ADDRESS_SIZE];
489
  struct symtab *sym;
490
  int gcc_minor;
483
491
484
  if (TYPE_CODE (ftype) == TYPE_CODE_PTR)
492
  if (TYPE_CODE (ftype) == TYPE_CODE_PTR)
485
    ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
493
    ftype = check_typedef (TYPE_TARGET_TYPE (ftype));
Lines 745-750 call_function_by_hand (struct value *function, int nargs, struct value **args) Link Here
745
    }
753
    }
746
  else
754
  else
747
    args_cleanup = make_cleanup (null_cleanup, NULL);
755
    args_cleanup = make_cleanup (null_cleanup, NULL);
756
    
757
  /* before we push the dummy call, we need to use the real_pc to determine 
758
     what gcc producer is used to generate this function, so it will notify
759
     this information to i386-tdep.c */
760
     sym = find_pc_symtab(real_pc);
761
     if (sym != NULL && sym->producer != NULL)
762
     {
763
        gcc_minor = producer_is_gcc_ge_4(sym->producer);
764
        if (gcc_minor>6)
765
            i386_windows_build_gt_gcc46 = 1;
766
        else
767
            i386_windows_build_gt_gcc46 = 0;
768
     }
769
     else
770
        i386_windows_build_gt_gcc46 = 0;
748
771
749
  /* Create the dummy stack frame.  Pass in the call dummy address as,
772
  /* Create the dummy stack frame.  Pass in the call dummy address as,
750
     presumably, the ABI code knows where, in the call dummy, the
773
     presumably, the ABI code knows where, in the call dummy, the

Return to bug 15559