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

Collapse All | Expand All

(-)a/gdb/i386-tdep.c (-2 / +73 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"
48
#include <string.h>
49
#include <string.h>
49
50
50
#include "i386-tdep.h"
51
#include "i386-tdep.h"
Lines 2529-2534 i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, Link Here
2529
  int i;
2530
  int i;
2530
  int write_pass;
2531
  int write_pass;
2531
  int args_space = 0;
2532
  int args_space = 0;
2533
  struct type *func_type = value_type (function);
2534
  int i386_windows_thiscall = 0;
2535
2536
  if (func_type)
2537
    {
2538
      func_type = check_typedef (func_type);
2539
2540
      if (TYPE_CODE (func_type) == TYPE_CODE_PTR)
2541
	func_type = check_typedef (TYPE_TARGET_TYPE (func_type));
2542
2543
      if ((TYPE_CODE (func_type) == TYPE_CODE_METHOD)
2544
	  && nargs > 0)
2545
	{
2546
	  CORE_ADDR funaddr = find_function_addr (function, NULL);
2547
	  struct symbol *funsym = find_pc_function (funaddr);
2548
	  if (funsym != NULL
2549
	      && SYMBOL_BLOCK_OPS (funsym))
2550
	    {
2551
	      struct symbol *thissym;
2552
	      thissym = lookup_block_symbol (funsym->ginfo.value.block,
2553
					     "this", VAR_DOMAIN);
2554
	      if (thissym != NULL
2555
		  && SYMBOL_COMPUTED_OPS (thissym)
2556
		  && SYMBOL_COMPUTED_OPS (thissym)->tracepoint_var_ref)
2557
		{
2558
		  struct axs_value av;
2559
		  struct agent_expr *ax =
2560
		    new_agent_expr (gdbarch, funaddr);
2561
		  volatile struct gdb_exception ex;
2562
2563
		  av.type = check_typedef (SYMBOL_TYPE (thissym));
2564
		  av.optimized_out = 0;
2565
2566
		  TRY_CATCH (ex, RETURN_MASK_ERROR)
2567
		    {
2568
		      SYMBOL_COMPUTED_OPS (thissym)->
2569
			tracepoint_var_ref (thissym, gdbarch, ax, &av);
2570
		    }
2571
		  if (ex.reason >= 0)
2572
		    {
2573
		      unsigned char espLoc[] = {
2574
			aop_reg, 0, I386_ESP_REGNUM,
2575
			aop_const8, 4,
2576
			aop_add,
2577
			aop_const8, 0xf4,
2578
			aop_ext, 8,
2579
			aop_add,
2580
		      };
2581
		      if (av.kind == axs_lvalue_register
2582
			  && av.u.reg == I386_ECX_REGNUM)
2583
			/* 'this' pointer is stored in register ECX.  */
2584
			i386_windows_thiscall = 1;
2585
		      else if (av.kind == axs_lvalue_memory
2586
			       && ax->len == sizeof (espLoc)
2587
			       && !memcmp (ax->buf, espLoc, sizeof (espLoc)))
2588
			/* 'this' pointer is copied from ECX to
2589
			   stack-relative -12 (0xf4), happens when
2590
			   comiled with -O0.  */
2591
			i386_windows_thiscall = 1;
2592
		    }
2593
2594
		  free_agent_expr (ax);
2595
		}
2596
	    }
2597
	}
2598
    }
2532
2599
2533
  /* Determine the total space required for arguments and struct
2600
  /* Determine the total space required for arguments and struct
2534
     return address in a first pass (allowing for 16-byte-aligned
2601
     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;
2618
	    args_space += 4;
2552
	}
2619
	}
2553
2620
2554
      for (i = 0; i < nargs; i++)
2621
      for (i = i386_windows_thiscall; i < nargs; i++)
2555
	{
2622
	{
2556
	  int len = TYPE_LENGTH (value_enclosing_type (args[i]));
2623
	  int len = TYPE_LENGTH (value_enclosing_type (args[i]));
2557
2624
Lines 2603-2608 i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function, Link Here
2603
  /* ...and fake a frame pointer.  */
2670
  /* ...and fake a frame pointer.  */
2604
  regcache_cooked_write (regcache, I386_EBP_REGNUM, buf);
2671
  regcache_cooked_write (regcache, I386_EBP_REGNUM, buf);
2605
2672
2673
  /* 'this' pointer needs to be in ECX.  */
2674
  if (i386_windows_thiscall)
2675
    regcache_cooked_write (regcache, I386_ECX_REGNUM,
2676
			   value_contents_all (args[0]));
2677
2606
  /* MarkK wrote: This "+ 8" is all over the place:
2678
  /* MarkK wrote: This "+ 8" is all over the place:
2607
     (i386_frame_this_id, i386_sigtramp_frame_this_id,
2679
     (i386_frame_this_id, i386_sigtramp_frame_this_id,
2608
     i386_dummy_id).  It's there, since all frame unwinders for
2680
     i386_dummy_id).  It's there, since all frame unwinders for
2609
- 

Return to bug 15559