Author: martin
Date: 2007-10-18 12:59:20 -0400 (Thu, 18 Oct 2007)
New Revision: 87767
Modified:
branches/martin/debugger-plophos/debugger/backend/BreakpointManager.cs
branches/martin/debugger-plophos/debugger/backend/SingleSteppingEngine.cs
branches/martin/debugger-plophos/debugger/backend/server/breakpoints.c
branches/martin/debugger-plophos/debugger/backend/server/breakpoints.h
branches/martin/debugger-plophos/debugger/backend/server/x86_64-arch.c
Log:
Modified: branches/martin/debugger-plophos/debugger/backend/BreakpointManager.cs
===================================================================
--- branches/martin/debugger-plophos/debugger/backend/BreakpointManager.cs
2007-10-18 16:38:30 UTC (rev 87766)
+++ branches/martin/debugger-plophos/debugger/backend/BreakpointManager.cs
2007-10-18 16:59:20 UTC (rev 87767)
@@ -32,6 +32,9 @@
static extern void mono_debugger_breakpoint_manager_unlock ();
[DllImport("monodebuggerserver")]
+ static extern bool
mono_debugger_breakpoint_manager_is_any_bpt_in_memory_area (IntPtr manager,
long start, int size);
+
+ [DllImport("monodebuggerserver")]
static extern int mono_debugger_breakpoint_info_get_id (IntPtr
info);
[DllImport("monodebuggerserver")]
@@ -234,6 +237,17 @@
}
}
+ public bool IsAnyBreakpointInMemoryArea (TargetAddress address,
int size)
+ {
+ Lock ();
+ try {
+ return
mono_debugger_breakpoint_manager_is_any_bpt_in_memory_area (
+ _manager, address.Address, size);
+ } finally {
+ Unlock ();
+ }
+ }
+
public void DomainUnload (Inferior inferior, int domain)
{
Lock ();
Modified:
branches/martin/debugger-plophos/debugger/backend/SingleSteppingEngine.cs
===================================================================
--- branches/martin/debugger-plophos/debugger/backend/SingleSteppingEngine.cs
2007-10-18 16:38:30 UTC (rev 87766)
+++ branches/martin/debugger-plophos/debugger/backend/SingleSteppingEngine.cs
2007-10-18 16:59:20 UTC (rev 87767)
@@ -3539,9 +3539,24 @@
protected override void DoExecute ()
{
- TargetBinaryWriter writer = new TargetBinaryWriter (16,
inferior.TargetInfo);
+ byte[] code_buffer = null;
+ int code_buffer_size = 0;
+ int code_buffer_offset = 0;
+
+ if
(sse.process.BreakpointManager.IsAnyBreakpointInMemoryArea (CallSite - 16, 32))
{
+ code_buffer = inferior.ReadBuffer (CallSite -
16, 32);
+ code_buffer_size = 32;
+ code_buffer_offset = 16;
+ }
+
+ TargetBinaryWriter writer = new TargetBinaryWriter (
+ 32 + code_buffer_size, inferior.TargetInfo);
writer.WriteInt64 (CallSite.Address);
writer.WriteInt64 (CallTarget.Address);
+ writer.WriteInt32 (code_buffer_size);
+ writer.WriteInt32 (code_buffer_offset);
+ if (code_buffer != null)
+ writer.WriteBuffer (code_buffer);
byte[] data = writer.Contents;
Modified: branches/martin/debugger-plophos/debugger/backend/server/breakpoints.c
===================================================================
--- branches/martin/debugger-plophos/debugger/backend/server/breakpoints.c
2007-10-18 16:38:30 UTC (rev 87766)
+++ branches/martin/debugger-plophos/debugger/backend/server/breakpoints.c
2007-10-18 16:59:20 UTC (rev 87767)
@@ -105,6 +105,27 @@
return ++last_breakpoint_id;
}
+gboolean
+mono_debugger_breakpoint_manager_is_any_bpt_in_memory_area (BreakpointManager
*bpm,
+ guint64 start,
guint32 size)
+{
+ int i;
+
+ for (i = 0; i < bpm->breakpoints->len; i++) {
+ BreakpointInfo *info = g_ptr_array_index (bpm->breakpoints, i);
+ guint64 offset;
+
+ if (info->is_hardware_bpt || !info->enabled)
+ continue;
+ if ((info->address < start) || (info->address >= start+size))
+ continue;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
int
mono_debugger_breakpoint_info_get_id (BreakpointInfo *info)
{
Modified: branches/martin/debugger-plophos/debugger/backend/server/breakpoints.h
===================================================================
--- branches/martin/debugger-plophos/debugger/backend/server/breakpoints.h
2007-10-18 16:38:30 UTC (rev 87766)
+++ branches/martin/debugger-plophos/debugger/backend/server/breakpoints.h
2007-10-18 16:59:20 UTC (rev 87767)
@@ -59,6 +59,10 @@
GPtrArray *
mono_debugger_breakpoint_manager_get_breakpoints (BreakpointManager *bpm);
+gboolean
+mono_debugger_breakpoint_manager_is_any_bpt_in_memory_area (BreakpointManager
*bpm,
+ guint64 start,
guint32 size);
+
void
mono_debugger_breakpoint_manager_remove (BreakpointManager *bpm,
BreakpointInfo *breakpoint);
Modified: branches/martin/debugger-plophos/debugger/backend/server/x86_64-arch.c
===================================================================
--- branches/martin/debugger-plophos/debugger/backend/server/x86_64-arch.c
2007-10-18 16:38:30 UTC (rev 87766)
+++ branches/martin/debugger-plophos/debugger/backend/server/x86_64-arch.c
2007-10-18 16:59:20 UTC (rev 87767)
@@ -35,6 +35,7 @@
guint64 rti_frame;
guint64 exc_address;
int saved_signal;
+ guint64 pushed_registers;
gboolean debug;
} CallbackData;
@@ -196,6 +197,34 @@
cdata = get_callback_data (arch);
if (cdata && (cdata->call_address == INFERIOR_REG_RIP
(arch->current_regs))) {
+ if (cdata->pushed_registers) {
+ guint64 pushed_regs [13];
+
+ g_message (G_STRLOC ": %Lx - %Lx - %Lx",
cdata->pushed_registers,
+ INFERIOR_REG_RIP (arch->current_regs),
+ INFERIOR_REG_RSP (arch->current_regs));
+
+ if (_server_ptrace_read_memory (handle,
cdata->pushed_registers, 104, &pushed_regs))
+ g_error (G_STRLOC ": Can't restore registers
after returning from a call");
+
+ g_message (G_STRLOC ": %Lx - %Lx",
+ INFERIOR_REG_RAX (cdata->saved_regs),
pushed_regs [0]);
+
+ INFERIOR_REG_RAX (cdata->saved_regs) = pushed_regs [0];
+ INFERIOR_REG_RBX (cdata->saved_regs) = pushed_regs [1];
+ INFERIOR_REG_RCX (cdata->saved_regs) = pushed_regs [2];
+ INFERIOR_REG_RDX (cdata->saved_regs) = pushed_regs [3];
+ INFERIOR_REG_RBP (cdata->saved_regs) = pushed_regs [4];
+ INFERIOR_REG_RSP (cdata->saved_regs) = pushed_regs [5];
+ INFERIOR_REG_RSI (cdata->saved_regs) = pushed_regs [6];
+ INFERIOR_REG_RDI (cdata->saved_regs) = pushed_regs [7];
+ INFERIOR_REG_RIP (cdata->saved_regs) = pushed_regs [8];
+ INFERIOR_REG_R12 (cdata->saved_regs) = pushed_regs [9];
+ INFERIOR_REG_R13 (cdata->saved_regs) = pushed_regs [10];
+ INFERIOR_REG_R14 (cdata->saved_regs) = pushed_regs [11];
+ INFERIOR_REG_R15 (cdata->saved_regs) = pushed_regs [12];
+ }
+
if (_server_ptrace_set_registers (inferior, &cdata->saved_regs)
!= COMMAND_ERROR_NONE)
g_error (G_STRLOC ": Can't restore registers after
returning from a call");
@@ -838,6 +867,7 @@
cdata->exc_address = 0;
cdata->callback_argument = callback_argument;
cdata->saved_signal = handle->inferior->last_signal;
+ cdata->pushed_registers = new_rsp + 8;
handle->inferior->last_signal = 0;
server_ptrace_write_memory (handle, (unsigned long) new_rsp, size,
code);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches