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

Collapse All | Expand All

(-)a/gdb/i386-tdep.c (-2 / +52 lines)
Lines 45-50 Link Here
45
#include "remote.h"
45
#include "remote.h"
46
#include "exceptions.h"
46
#include "exceptions.h"
47
#include "gdb_assert.h"
47
#include "gdb_assert.h"
48
#include "infcall.h"
49
#include "dwarf2.h"
48
#include <string.h>
50
#include <string.h>
49
51
50
#include "i386-tdep.h"
52
#include "i386-tdep.h"
Lines 2529-2534 i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, Link Here
2529
  int i;
2531
  int i;
2530
  int write_pass;
2532
  int write_pass;
2531
  int args_space = 0;
2533
  int args_space = 0;
2534
  struct type *func_type = value_type (function);
2535
  int i386_windows_thiscall = 0;
2536
2537
  if (func_type)
2538
    {
2539
      func_type = check_typedef (func_type);
2540
2541
      if (TYPE_CODE (func_type) == TYPE_CODE_PTR)
2542
	func_type = check_typedef (TYPE_TARGET_TYPE (func_type));
2543
2544
      if ((TYPE_CODE (func_type) == TYPE_CODE_METHOD)
2545
	  && nargs > 0)
2546
	{
2547
	  CORE_ADDR funaddr = find_function_addr (function, NULL);
2548
	  struct symbol *funsym = find_pc_function (funaddr);
2549
	  if (funsym != NULL
2550
	      && SYMBOL_BLOCK_OPS (funsym))
2551
	    {
2552
	      struct symbol *thissym;
2553
	      thissym = lookup_block_symbol (funsym->ginfo.value.block,
2554
					     "this", VAR_DOMAIN);
2555
	      if (thissym != NULL)
2556
		{
2557
		  const gdb_byte *start;
2558
		  size_t length;
2559
		  const struct symbol_block_ops *ops_block =
2560
		    SYMBOL_BLOCK_OPS (funsym);
2561
		  ops_block->find_frame_base_location (thissym, 0,
2562
						       &start, &length);
2563
		  if (length == 1
2564
		      && start[0] == DW_OP_reg1)
2565
		    /* 'this' pointer is stored in register ECX.  */
2566
		    i386_windows_thiscall = 1;
2567
		  else if (length == 2
2568
		      && start[0] == DW_OP_fbreg
2569
		      && start[1] == 0x74)
2570
		    /* 'this' pointer is copied from ECX to
2571
		       stack-relative -12 (0x74), happens when
2572
		       comiled with -O0.  */
2573
		    i386_windows_thiscall = 1;
2574
		}
2575
	    }
2576
	}
2577
    }
2532
2578
2533
  /* Determine the total space required for arguments and struct
2579
  /* Determine the total space required for arguments and struct
2534
     return address in a first pass (allowing for 16-byte-aligned
2580
     return address in a first pass (allowing for 16-byte-aligned
Lines 2551-2557 i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, Link Here
2551
	    args_space += 4;
2597
	    args_space += 4;
2552
	}
2598
	}
2553
2599
2554
      for (i = 0; i < nargs; i++)
2600
      for (i = i386_windows_thiscall; i < nargs; i++)
2555
	{
2601
	{
2556
	  int len = TYPE_LENGTH (value_enclosing_type (args[i]));
2602
	  int len = TYPE_LENGTH (value_enclosing_type (args[i]));
2557
2603
Lines 2603-2608 i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, Link Here
2603
  /* ...and fake a frame pointer.  */
2649
  /* ...and fake a frame pointer.  */
2604
  regcache_cooked_write (regcache, I386_EBP_REGNUM, buf);
2650
  regcache_cooked_write (regcache, I386_EBP_REGNUM, buf);
2605
2651
2652
  /* 'this' pointer needs to be in ECX.  */
2653
  if (i386_windows_thiscall)
2654
    regcache_cooked_write (regcache, I386_ECX_REGNUM,
2655
			   value_contents_all (args[0]));
2656
2606
  /* MarkK wrote: This "+ 8" is all over the place:
2657
  /* MarkK wrote: This "+ 8" is all over the place:
2607
     (i386_frame_this_id, i386_sigtramp_frame_this_id,
2658
     (i386_frame_this_id, i386_sigtramp_frame_this_id,
2608
     i386_dummy_id).  It's there, since all frame unwinders for
2659
     i386_dummy_id).  It's there, since all frame unwinders for
2609
- 

Return to bug 15559