Author: martin
Date: 2007-10-31 12:06:01 -0500 (Wed, 31 Oct 2007)
New Revision: 88579
Modified:
trunk/debugger/ChangeLog
trunk/debugger/backend/Inferior.cs
trunk/debugger/backend/SingleSteppingEngine.cs
trunk/debugger/backend/arch/Opcodes.cs
trunk/debugger/backend/arch/Opcodes_I386.cs
trunk/debugger/backend/arch/Opcodes_X86_64.cs
trunk/debugger/backend/server/library.c
trunk/debugger/backend/server/server.h
trunk/debugger/backend/server/x86_64-arch.c
Log:
2007-10-31 Martin Baulig <[EMAIL PROTECTED]>
* backend/arch/Architecture.cs
(Architecture.Opcodes.GenerateNopInstruction): New public property.
* backend/SingleSteppingEngine.cs
(SSE.step_over_breakpoint): Use Opcodes.GenerateNopInstruction()
instead of encoding it here.
* backend/server/server.h
(mono_debugger_server_execute_instruction): Removed the
`original_size' argument; replaced `push_retaddr' by `update_ip'.
Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog 2007-10-31 16:34:05 UTC (rev 88578)
+++ trunk/debugger/ChangeLog 2007-10-31 17:06:01 UTC (rev 88579)
@@ -7,12 +7,16 @@
2007-10-31 Martin Baulig <[EMAIL PROTECTED]>
* backend/arch/Architecture.cs
- (Architecture.Opcodes): New public property.
+ (Architecture.Opcodes.GenerateNopInstruction): New public property.
* backend/SingleSteppingEngine.cs
- (SSE.step_over_breakpoint): Use Opcodes.GenerateJumpInstruction()
+ (SSE.step_over_breakpoint): Use Opcodes.GenerateNopInstruction()
instead of encoding it here.
+ * backend/server/server.h
+ (mono_debugger_server_execute_instruction): Removed the
+ `original_size' argument; replaced `push_retaddr' by `update_ip'.
+
2007-10-31 Martin Baulig <[EMAIL PROTECTED]>
* backend/arch/Opcodes.cs
Modified: trunk/debugger/backend/Inferior.cs
===================================================================
--- trunk/debugger/backend/Inferior.cs 2007-10-31 16:34:05 UTC (rev 88578)
+++ trunk/debugger/backend/Inferior.cs 2007-10-31 17:06:01 UTC (rev 88579)
@@ -117,7 +117,7 @@
static extern TargetError
mono_debugger_server_call_method_invoke (IntPtr handle, long invoke_method,
long method_address, int num_params, int blob_size, IntPtr param_data, IntPtr
offset_data, IntPtr blob_data, long callback_argument, bool debug);
[DllImport("monodebuggerserver")]
- static extern TargetError
mono_debugger_server_execute_instruction (IntPtr handle, IntPtr instruction,
int orig_insn_size, int insn_size, bool push_retaddr);
+ static extern TargetError
mono_debugger_server_execute_instruction (IntPtr handle, IntPtr instruction,
int insn_size, bool update_ip);
[DllImport("monodebuggerserver")]
static extern TargetError
mono_debugger_server_insert_breakpoint (IntPtr handle, long address, out int
breakpoint);
@@ -445,8 +445,7 @@
}
}
- public void ExecuteInstruction (byte[] instruction, int
orig_insn_size,
- bool push_retaddr)
+ public void ExecuteInstruction (byte[] instruction, bool
update_ip)
{
check_disposed ();
@@ -456,8 +455,7 @@
Marshal.Copy (instruction, 0, data,
instruction.Length);
check_error
(mono_debugger_server_execute_instruction (
- server_handle, data, orig_insn_size,
instruction.Length,
- push_retaddr));
+ server_handle, data,
instruction.Length, update_ip));
} finally {
Marshal.FreeHGlobal (data);
}
Modified: trunk/debugger/backend/SingleSteppingEngine.cs
===================================================================
--- trunk/debugger/backend/SingleSteppingEngine.cs 2007-10-31 16:34:05 UTC
(rev 88578)
+++ trunk/debugger/backend/SingleSteppingEngine.cs 2007-10-31 17:06:01 UTC
(rev 88579)
@@ -923,7 +923,8 @@
Instruction instruction =
inferior.Architecture.ReadInstruction (
inferior, inferior.CurrentFrame);
- Console.WriteLine ("EXECUTE INSTRUCTION: {0}",
instruction);
+ Console.WriteLine ("EXECUTE INSTRUCTION: {0} {1}",
+ singlestep, instruction);
if ((instruction == null) ||
!instruction.HasInstructionSize ||
!process.IsManagedApplication) {
@@ -931,20 +932,30 @@
return true;
}
- if (!singlestep && instruction.InterpretInstruction
(inferior))
- return false;
+ if (instruction.InterpretInstruction (inferior)) {
+ if (!singlestep)
+ return false;
+ Console.WriteLine ("ACHTUNG ACHTUNG!");
+ byte[] nop_insn =
Architecture.Opcodes.GenerateNopInstruction ();
+ inferior.ExecuteInstruction (nop_insn, false);
+ return true;
+ }
+
+#if FIXME
if ((instruction.InstructionType ==
Instruction.Type.Call) ||
(instruction.InstructionType ==
Instruction.Type.IndirectCall)) {
TargetAddress target =
instruction.GetEffectiveAddress (inferior);
Console.WriteLine ("EXECUTE CALL: {0} {1}",
inferior.CurrentFrame, target);
+ Console.WriteLine ("ACHTUNG ACHTUNG!");
byte[] jump_insn =
Architecture.Opcodes.GenerateJumpInstruction (target);
inferior.ExecuteInstruction (jump_insn,
instruction.InstructionSize, true);
return true;
}
+#endif
if (instruction.IsIpRelative) {
PushOperation (new OperationStepOverBreakpoint
(this, index, until));
@@ -954,7 +965,7 @@
Console.WriteLine ("EXECUTE INSTRUCTION #1: {0} {1}",
instruction,
TargetBinaryReader.HexDump
(instruction.Code));
- inferior.ExecuteInstruction (instruction.Code,
instruction.InstructionSize, false);
+ inferior.ExecuteInstruction (instruction.Code, true);
return true;
}
Modified: trunk/debugger/backend/arch/Opcodes.cs
===================================================================
--- trunk/debugger/backend/arch/Opcodes.cs 2007-10-31 16:34:05 UTC (rev
88578)
+++ trunk/debugger/backend/arch/Opcodes.cs 2007-10-31 17:06:01 UTC (rev
88579)
@@ -8,7 +8,7 @@
internal abstract Instruction ReadInstruction
(TargetMemoryAccess memory,
TargetAddress
address);
- internal abstract byte[] GenerateJumpInstruction (TargetAddress
address);
+ internal abstract byte[] GenerateNopInstruction ();
//
// IDisposable
Modified: trunk/debugger/backend/arch/Opcodes_I386.cs
===================================================================
--- trunk/debugger/backend/arch/Opcodes_I386.cs 2007-10-31 16:34:05 UTC (rev
88578)
+++ trunk/debugger/backend/arch/Opcodes_I386.cs 2007-10-31 17:06:01 UTC (rev
88579)
@@ -13,9 +13,9 @@
get { return false; }
}
- internal override byte[] GenerateJumpInstruction (TargetAddress
address)
+ internal override byte[] GenerateNopInstruction ()
{
- return new byte[0];
+ return new byte[] { 0x90 };
}
}
}
Modified: trunk/debugger/backend/arch/Opcodes_X86_64.cs
===================================================================
--- trunk/debugger/backend/arch/Opcodes_X86_64.cs 2007-10-31 16:34:05 UTC
(rev 88578)
+++ trunk/debugger/backend/arch/Opcodes_X86_64.cs 2007-10-31 17:06:01 UTC
(rev 88579)
@@ -13,16 +13,9 @@
get { return true; }
}
- internal override byte[] GenerateJumpInstruction (TargetAddress
target)
+ internal override byte[] GenerateNopInstruction ()
{
- TargetBinaryWriter writer = new TargetBinaryWriter (14,
TargetMemoryInfo);
-
- writer.WriteByte (0xff);
- writer.WriteByte (0x25);
- writer.WriteInt32 (0);
- writer.WriteAddress (target);
-
- return writer.Contents;
+ return new byte[] { 0x90 };
}
}
}
Modified: trunk/debugger/backend/server/library.c
===================================================================
--- trunk/debugger/backend/server/library.c 2007-10-31 16:34:05 UTC (rev
88578)
+++ trunk/debugger/backend/server/library.c 2007-10-31 17:06:01 UTC (rev
88579)
@@ -248,14 +248,13 @@
ServerCommandError
mono_debugger_server_execute_instruction (ServerHandle *handle, const guint8
*instruction,
- guint32 orig_insn_size, guint32
insn_size,
- gboolean push_retaddr)
+ guint32 insn_size, gboolean update_ip)
{
if (!global_vtable->execute_instruction)
return COMMAND_ERROR_NOT_IMPLEMENTED;
return (* global_vtable->execute_instruction) (
- handle, instruction, orig_insn_size, insn_size, push_retaddr);
+ handle, instruction, insn_size, update_ip);
}
ServerCommandError
Modified: trunk/debugger/backend/server/server.h
===================================================================
--- trunk/debugger/backend/server/server.h 2007-10-31 16:34:05 UTC (rev
88578)
+++ trunk/debugger/backend/server/server.h 2007-10-31 17:06:01 UTC (rev
88579)
@@ -258,9 +258,8 @@
ServerCommandError (* execute_instruction) (ServerHandle *handle,
const guint8
*instruction,
- guint32
orig_size,
guint32 size,
- gboolean
push_retaddr);
+ gboolean
update_ip);
ServerCommandError (* mark_rti_frame) (ServerHandle
*handle);
@@ -500,9 +499,8 @@
ServerCommandError
mono_debugger_execute_instruction (ServerHandle *handle,
const guint8 *instruction,
- guint32
original_instruction_size,
guint32
instruction_size,
- gboolean push_retaddr);
+ gboolean update_ip);
ServerCommandError
mono_debugger_mark_rti_framenvoke (ServerHandle *handle);
Modified: trunk/debugger/backend/server/x86_64-arch.c
===================================================================
--- trunk/debugger/backend/server/x86_64-arch.c 2007-10-31 16:34:05 UTC (rev
88578)
+++ trunk/debugger/backend/server/x86_64-arch.c 2007-10-31 17:06:01 UTC (rev
88579)
@@ -19,8 +19,7 @@
{
int slot;
int insn_size;
- int orig_insn_size;
- gboolean pushed_retaddr;
+ gboolean update_ip;
guint64 code_address;
guint64 original_rip;
} CodeBufferData;
@@ -276,15 +275,17 @@
cbuffer = arch->code_buffer;
if (cbuffer) {
- g_message (G_STRLOC ": %p,%d - %Lx - %d,%d - %Lx,%Lx", cbuffer,
cbuffer->pushed_retaddr,
- cbuffer->original_rip, cbuffer->orig_insn_size,
cbuffer->insn_size,
- cbuffer->code_address, INFERIOR_REG_RIP
(arch->current_regs));
+ g_message (G_STRLOC ": %p,%d - %Lx - %d - %Lx,%Lx", cbuffer,
cbuffer->update_ip,
+ cbuffer->original_rip, cbuffer->insn_size,
cbuffer->code_address,
+ INFERIOR_REG_RIP (arch->current_regs));
+#if 0
if (cbuffer->pushed_retaddr) {
g_free (cbuffer);
arch->code_buffer = NULL;
return STOP_ACTION_STOPPED;
}
+#endif
if (cbuffer->code_address + cbuffer->insn_size !=
INFERIOR_REG_RIP (arch->current_regs)) {
g_warning (G_STRLOC ": %Lx,%d - %Lx - %Lx",
@@ -294,7 +295,9 @@
return STOP_ACTION_STOPPED;
}
- INFERIOR_REG_RIP (arch->current_regs) = cbuffer->original_rip +
cbuffer->orig_insn_size;
+ INFERIOR_REG_RIP (arch->current_regs) = cbuffer->original_rip;
+ if (cbuffer->update_ip)
+ INFERIOR_REG_RIP (arch->current_regs) +=
cbuffer->insn_size;
if (_server_ptrace_set_registers (inferior,
&arch->current_regs) != COMMAND_ERROR_NONE) {
g_error (G_STRLOC ": Can't restore registers");
}
@@ -1122,7 +1125,7 @@
static ServerCommandError
server_ptrace_execute_instruction (ServerHandle *handle, const guint8
*instruction,
- guint32 orig_size, guint32 size, gboolean
push_retaddr)
+ guint32 size, gboolean update_ip)
{
MonoRuntimeInfo *runtime;
ServerCommandError result;
@@ -1149,8 +1152,7 @@
data = g_new0 (CodeBufferData, 1);
data->slot = slot;
data->insn_size = size;
- data->orig_insn_size = orig_size;
- data->pushed_retaddr = push_retaddr;
+ data->update_ip = update_ip;
data->original_rip = INFERIOR_REG_RIP (handle->arch->current_regs);
data->code_address = code_address;
@@ -1160,17 +1162,6 @@
if (result != COMMAND_ERROR_NONE)
return result;
- if (push_retaddr) {
- long old_rsp = INFERIOR_REG_RSP (handle->arch->current_regs);
- long retaddr = INFERIOR_REG_RIP (handle->arch->current_regs) +
orig_size;
-
- result = server_ptrace_write_memory (handle, old_rsp - 8, 8,
&retaddr);
- if (result != COMMAND_ERROR_NONE)
- return result;
-
- INFERIOR_REG_RSP (handle->arch->current_regs) -= 8;
- }
-
INFERIOR_REG_RIP (handle->arch->current_regs) = code_address;
result = _server_ptrace_set_registers (handle->inferior,
&handle->arch->current_regs);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches