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

Commit

Permalink
Thread.AbortInvocation() now takes a 'long rti_id' argument to only a…
Browse files Browse the repository at this point in the history
…bort this specific invocation.

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

	* classes/Thread.cs
	(Thread.AbortInvocation): Added `long rti_id' argument.

	* backend/SingleSteppingEngine.cs
	(SSE.AbortInvocation): Implemented this using `OperationReturn'.

	* classes/TargetException.cs
	(TargetError): Added `NoInvocation'.

svn path=/branches/mono-2-4-1/debugger/; revision=134418
  • Loading branch information
Martin Baulig committed May 19, 2009
1 parent f6ff498 commit f771946
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 15 deletions.
17 changes: 11 additions & 6 deletions ChangeLog
@@ -1,3 +1,14 @@
2009-05-19 Martin Baulig <martin@ximian.com>

* classes/Thread.cs
(Thread.AbortInvocation): Added `long rti_id' argument.

* backend/SingleSteppingEngine.cs
(SSE.AbortInvocation): Implemented this using `OperationReturn'.

* classes/TargetException.cs
(TargetError): Added `NoInvocation'.

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

* backend/Inferior.cs
Expand Down Expand Up @@ -29,12 +40,6 @@
(Backtrace.TryUnwind): Improve handling of callback frames; also
check `until'.

* backend/ThreadServant.cs
(ThreadServant.AbortInvocation): Removed.

* classes/Thread.cs
(Thread.AbortInvocation): Removed.

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

* classes/Thread.cs
Expand Down
60 changes: 59 additions & 1 deletion backend/SingleSteppingEngine.cs
Expand Up @@ -1773,7 +1773,7 @@ public override CommandResult Return (ReturnMode mode)
if (mode == ReturnMode.Invocation) {
Inferior.CallbackFrame cframe = inferior.GetCallbackFrame (current_frame.StackPointer, false);
if (cframe == null)
throw new TargetException (TargetError.InvalidReturn, "No invocation found.");
throw new TargetException (TargetError.NoInvocation);
bt.GetBacktrace (this, inferior, Backtrace.Mode.Native, cframe.StackPointer, -1);
for (int i = 0; i < bt.Count; i++) {
if (bt.Frames [i].Type == FrameType.Normal)
Expand Down Expand Up @@ -1828,6 +1828,63 @@ public override CommandResult Return (ReturnMode mode)
});
}

public override CommandResult AbortInvocation (long rti_id)
{
return (CommandResult) SendCommand (delegate {
if (!engine_stopped) {
Report.Debug (DebugFlags.Wait,
"{0} not stopped", this);
throw new TargetException (TargetError.NotStopped);
}

if (current_frame == null)
throw new TargetException (TargetError.NoStack);

process.UpdateSymbolTable (inferior);

if (process.IsManagedApplication)
throw new TargetException (TargetError.InvalidReturn, "Not a managed application.");

Inferior.CallbackFrame cframe = inferior.GetCallbackFrame (current_frame.StackPointer, false);

bool found = false;
foreach (OperationRuntimeInvoke rti in rti_stack) {
if (rti.ID == rti_id) {
found = true;
break;
}
}

if (!found) {
if ((cframe == null) || (cframe.ID != rti_id))
throw new TargetException (TargetError.NoInvocation);
} else {
if (cframe == null)
throw new TargetException (TargetError.InvalidReturn, "No invocation found.");
else if (cframe.ID != rti_id)
throw new TargetException (TargetError.InvalidReturn,
"Requested to abort invocation {0}, but current invocation has id {1}.",
rti_id, cframe.ID);
}

Backtrace bt = new Backtrace (current_frame);

bt.GetBacktrace (this, inferior, Backtrace.Mode.Native, cframe.StackPointer, -1);
for (int i = 0; i < bt.Count; i++) {
if (bt.Frames [i].Type == FrameType.Normal)
continue;
else if ((bt.Frames [i].Type == FrameType.RuntimeInvoke) && (i + 1 == bt.Count))
break;
throw new TargetException (TargetError.InvalidReturn, "Cannot abort an invocation which contains non-managed frames.");
}

if (bt.Count < 2)
throw new TargetException (TargetError.NoStack);

return StartOperation (new OperationReturn (this, bt, ReturnMode.Invocation));
});
}

public override Backtrace GetBacktrace (Backtrace.Mode mode, int max_frames)
{
return (Backtrace) SendCommand (delegate {
Expand Down Expand Up @@ -3715,6 +3772,7 @@ protected override void DoExecute ()
if (helper != null)
throw new InternalError ("{0} rti already has a helper operation", sse);
helper = new OperationRuntimeInvokeHelper (sse, this);
Result.ID = helper.ID;
sse.PushOperation (helper);
}

Expand Down
2 changes: 2 additions & 0 deletions backend/ThreadServant.cs
Expand Up @@ -247,6 +247,8 @@ internal void SetDaemon ()

public abstract CommandResult Return (ReturnMode mode);

public abstract CommandResult AbortInvocation (long ID);

public string PrintRegisters (StackFrame frame)
{
return Architecture.PrintRegisters (frame);
Expand Down
5 changes: 5 additions & 0 deletions backend/arch/CoreFile.cs
Expand Up @@ -611,6 +611,11 @@ public override CommandResult Return (ReturnMode mode)
throw new InvalidOperationException ();
}

public override CommandResult AbortInvocation (long ID)
{
throw new InvalidOperationException ();
}

protected class CoreFileTargetAccess : TargetMemoryAccess
{
public readonly CoreFileThread Thread;
Expand Down
8 changes: 4 additions & 4 deletions classes/ExpressionEvaluator.cs
Expand Up @@ -82,7 +82,7 @@ public interface IEvaluator
if (!rti.CompletedEvent.WaitOne (timeout, false)) {
rti.Abort ();
rti.CompletedEvent.WaitOne ();
thread.AbortInvocation ();
thread.AbortInvocation (rti.ID);
return EvaluationResult.Timeout;
}

Expand All @@ -95,7 +95,7 @@ public interface IEvaluator
result = rti.ExceptionMessage;
return EvaluationResult.Exception;
} else if (rti.ReturnObject == null) {
thread.AbortInvocation ();
thread.AbortInvocation (rti.ID);
return EvaluationResult.UnknownError;
}
} catch (TargetException ex) {
Expand Down Expand Up @@ -134,7 +134,7 @@ public interface IEvaluator
if (!rti.CompletedEvent.WaitOne (timeout, false)) {
rti.Abort ();
rti.CompletedEvent.WaitOne ();
thread.AbortInvocation ();
thread.AbortInvocation (rti.ID);
result = null;
return EvaluationResult.Timeout;
}
Expand All @@ -151,7 +151,7 @@ public interface IEvaluator
error = rti.ExceptionMessage;
return EvaluationResult.Exception;
} else if (rti.ReturnObject == null) {
thread.AbortInvocation ();
thread.AbortInvocation (rti.ID);
return EvaluationResult.UnknownError;
}

Expand Down
5 changes: 4 additions & 1 deletion classes/TargetException.cs
Expand Up @@ -33,7 +33,8 @@ public enum TargetError {
InvocationException,
LocationInvalid,
CannotDetach,
InvalidReturn
InvalidReturn,
NoInvocation
}
#endregion

Expand Down Expand Up @@ -109,6 +110,8 @@ protected static string GetMessage (TargetError type)
"attach to it.";
case TargetError.InvalidReturn:
return "Cannot return from this kind of stack frame.";
case TargetError.NoInvocation:
return "No invocation found.";
default:
return "Unknown error";
}
Expand Down
22 changes: 19 additions & 3 deletions classes/Thread.cs
Expand Up @@ -658,10 +658,25 @@ public void Return (ReturnMode mode)
result.Wait ();
}

[Obsolete("FUCK")]
public void AbortInvocation ()
public bool AbortInvocation (long rti_id)
{
throw new InternalError ();
CommandResult result;

lock (this) {
check_alive ();
try {
result = servant.AbortInvocation (rti_id);
} catch (TargetException ex) {
if (ex.Type == TargetError.NoInvocation)
return false;
throw;
}
if (result == null)
return false;
}

result.Wait ();
return true;
}

public string PrintRegisters (StackFrame frame)
Expand Down Expand Up @@ -922,6 +937,7 @@ public override void Abort ()
thread.Stop ();
}

public long ID;
public bool InvocationCompleted;
public TargetObject ReturnObject;
public string ExceptionMessage;
Expand Down

0 comments on commit f771946

Please sign in to comment.