Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
**** Backport of 139424 ****
Browse files Browse the repository at this point in the history
2009-08-05  Martin Baulig  <martin@ximian.com>

	**** Backport of 139424 ****

	* backend/server/x86_64-arch.c
	(find_code_buffer_slot): Return a different slot each time we're
	called until we iterated over the entire buffer; it looks like
	there's a very weird race condition somewhere in the kernel which
	doesn't always flush the cpu's instruction cache when modifying
	the current instruction and then immediately executing it.
	(x86_arch_child_stopped): Return `STOP_ACTION_INTERNAL_ERROR' if
	we stopped at an unexpected location inside the code buffer.

	* backend/server/i386-arch.c
	(find_code_buffer_slot): No idea whether we need this here as
	well, but it doesn't hurt doing it here as well.

	* backend/server/x86-arch.h
	(ChildStoppedAction): Added `STOP_ACTION_INTERNAL_ERROR'.

	* backend/server/server.h
	(ServerStatusMessageType): Added `MESSAGE_INTERNAL_ERROR'.

	* backend/Inferior.cs
	(Inferior.ChildEventType): Added `INTERNAL_ERROR'.

svn path=/branches/mono-2-4-2/debugger/; revision=139432
  • Loading branch information
Martin Baulig committed Aug 5, 2009
1 parent d7821e9 commit dd54c5d
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 4 deletions.
26 changes: 26 additions & 0 deletions ChangeLog
@@ -1,3 +1,29 @@
2009-08-05 Martin Baulig <martin@ximian.com>

**** Backport of 139424 ****

* backend/server/x86_64-arch.c
(find_code_buffer_slot): Return a different slot each time we're
called until we iterated over the entire buffer; it looks like
there's a very weird race condition somewhere in the kernel which
doesn't always flush the cpu's instruction cache when modifying
the current instruction and then immediately executing it.
(x86_arch_child_stopped): Return `STOP_ACTION_INTERNAL_ERROR' if
we stopped at an unexpected location inside the code buffer.

* backend/server/i386-arch.c
(find_code_buffer_slot): No idea whether we need this here as
well, but it doesn't hurt doing it here as well.

* backend/server/x86-arch.h
(ChildStoppedAction): Added `STOP_ACTION_INTERNAL_ERROR'.

* backend/server/server.h
(ServerStatusMessageType): Added `MESSAGE_INTERNAL_ERROR'.

* backend/Inferior.cs
(Inferior.ChildEventType): Added `INTERNAL_ERROR'.

2009-08-05 Martin Baulig <martin@ximian.com>

**** Backport of 139423 ****
Expand Down
1 change: 1 addition & 0 deletions backend/Inferior.cs
Expand Up @@ -207,6 +207,7 @@ internal enum ChildEventType {
CHILD_NOTIFICATION,
CHILD_INTERRUPTED,
RUNTIME_INVOKE_DONE,
INTERNAL_ERROR,

UNHANDLED_EXCEPTION = 4001,
THROW_EXCEPTION,
Expand Down
7 changes: 7 additions & 0 deletions backend/SingleSteppingEngine.cs
Expand Up @@ -389,6 +389,13 @@ public void ProcessEvent (Inferior.ChildEvent cevent)
OperationCompleted (new TargetEventArgs (TargetEventType.TargetSignaled, arg));
return;

case Inferior.ChildEventType.INTERNAL_ERROR:
frame_changed (inferior.CurrentFrame, null);
Report.Error ("{0} got {1} at {2} while executing {2}", this, message,
inferior.CurrentFrame, current_operation);
OperationCompleted (new TargetEventArgs (TargetEventType.TargetSignaled, -1));
return true;

case Inferior.ChildEventType.CHILD_EXITED:
OperationCompleted (new TargetEventArgs (TargetEventType.TargetExited, arg));
return;
Expand Down
11 changes: 11 additions & 0 deletions backend/server/i386-arch.c
Expand Up @@ -1153,11 +1153,22 @@ find_code_buffer_slot (MonoRuntimeInfo *runtime)
{
int i;

for (i = runtime->executable_code_last_slot + 1; i < runtime->executable_code_total_chunks; i++) {
if (runtime->executable_code_bitfield [i])
continue;

runtime->executable_code_bitfield [i] = 1;
runtime->executable_code_last_slot = i;
return i;
}

runtime->executable_code_last_slot = 0;
for (i = 0; i < runtime->executable_code_total_chunks; i++) {
if (runtime->executable_code_bitfield [i])
continue;

runtime->executable_code_bitfield [i] = 1;
runtime->executable_code_last_slot = i;
return i;
}

Expand Down
4 changes: 3 additions & 1 deletion backend/server/server.h
Expand Up @@ -54,7 +54,8 @@ typedef enum {
MESSAGE_CHILD_CALLED_EXIT,
MESSAGE_CHILD_NOTIFICATION,
MESSAGE_CHILD_INTERRUPTED,
MESSAGE_RUNTIME_INVOKE_DONE
MESSAGE_RUNTIME_INVOKE_DONE,
MESSAGE_INTERNAL_ERROR
} ServerStatusMessageType;

typedef struct {
Expand Down Expand Up @@ -94,6 +95,7 @@ typedef struct
/* Private */
guint8 *breakpoint_table_bitfield;
guint8 *executable_code_bitfield;
guint32 executable_code_last_slot;
} MonoRuntimeInfo;

/* This is an opaque data structure which the backend may use to store stuff. */
Expand Down
3 changes: 2 additions & 1 deletion backend/server/x86-arch.h
Expand Up @@ -12,7 +12,8 @@ typedef enum {
STOP_ACTION_CALLBACK,
STOP_ACTION_CALLBACK_COMPLETED,
STOP_ACTION_NOTIFICATION,
STOP_ACTION_RTI_DONE
STOP_ACTION_RTI_DONE,
STOP_ACTION_INTERNAL_ERROR
} ChildStoppedAction;

typedef enum {
Expand Down
3 changes: 3 additions & 0 deletions backend/server/x86-ptrace.c
Expand Up @@ -347,6 +347,9 @@ server_ptrace_dispatch_event (ServerHandle *handle, guint32 status, guint64 *arg
*data1 = retval;
*data2 = retval2;
return MESSAGE_RUNTIME_INVOKE_DONE;

case STOP_ACTION_INTERNAL_ERROR:
return MESSAGE_INTERNAL_ERROR;
}

g_assert_not_reached ();
Expand Down
15 changes: 13 additions & 2 deletions backend/server/x86_64-arch.c
Expand Up @@ -294,7 +294,7 @@ x86_arch_child_stopped (ServerHandle *handle, int stopsig,
if (cbuffer->code_address + cbuffer->insn_size != INFERIOR_REG_RIP (arch->current_regs)) {
char buffer [1024];

g_warning (G_STRLOC ": %Lx,%d - %Lx - %Lx",
g_warning (G_STRLOC ": %d - %Lx,%d - %Lx - %Lx", cbuffer->slot,
cbuffer->code_address, cbuffer->insn_size,
cbuffer->code_address + cbuffer->insn_size,
INFERIOR_REG_RIP (arch->current_regs));
Expand All @@ -304,7 +304,7 @@ x86_arch_child_stopped (ServerHandle *handle, int stopsig,
buffer [0], buffer [1], buffer [2], buffer [3], buffer [4],
buffer [5], buffer [6], buffer [7]);

return STOP_ACTION_STOPPED;
return STOP_ACTION_INTERNAL_ERROR;
}

INFERIOR_REG_RIP (arch->current_regs) = cbuffer->original_rip;
Expand Down Expand Up @@ -1202,11 +1202,22 @@ find_code_buffer_slot (MonoRuntimeInfo *runtime)
{
int i;

for (i = runtime->executable_code_last_slot + 1; i < runtime->executable_code_total_chunks; i++) {
if (runtime->executable_code_bitfield [i])
continue;

runtime->executable_code_bitfield [i] = 1;
runtime->executable_code_last_slot = i;
return i;
}

runtime->executable_code_last_slot = 0;
for (i = 0; i < runtime->executable_code_total_chunks; i++) {
if (runtime->executable_code_bitfield [i])
continue;

runtime->executable_code_bitfield [i] = 1;
runtime->executable_code_last_slot = i;
return i;
}

Expand Down

0 comments on commit dd54c5d

Please sign in to comment.