Browse Source

Added ExceptionThrown event; Some code moved to NDebugger.Pause

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1682 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 19 years ago
parent
commit
e035a893a6
  1. 8
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/ExceptionHistoryPad.cs
  2. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs
  3. 42
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  4. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  5. 31
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/DebuggerEvents/DebuggingIsResumingEventArgs.cs
  6. 47
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/DebuggerEvents/DebuggingPausedEventArgs.cs
  7. 37
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/ExceptionEventArgs.cs
  8. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/MTA2STA.cs
  9. 8
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
  10. 54
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs
  11. 13
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs

8
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/ExceptionHistoryPad.cs

@ -69,11 +69,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -69,11 +69,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
exceptions.Clear();
RefreshPad();
};
debuggerCore.DebuggingPaused += delegate (object sender, DebuggingPausedEventArgs e) {
if (e.Reason == PausedReason.Exception) {
exceptions.Add(debuggerCore.SelectedThread.CurrentException);
RefreshPad();
}
debuggerCore.ExceptionThrown += delegate (object sender, ExceptionEventArgs e) {
exceptions.Add(e.Exception);
RefreshPad();
};
}

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/DynamicTreeDebuggerRow.cs

@ -166,7 +166,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -166,7 +166,7 @@ namespace ICSharpCode.SharpDevelop.Services
if (Variable.Debugger.IsPaused) {
action();
} else {
EventHandler<DebuggingPausedEventArgs> onDebuggingPaused = null;
EventHandler<DebuggerEventArgs> onDebuggingPaused = null;
onDebuggingPaused = delegate {
action();
Variable.Debugger.DebuggingPaused -= onDebuggingPaused;

42
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

@ -256,6 +256,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -256,6 +256,7 @@ namespace ICSharpCode.SharpDevelop.Services
debugger.ProcessStarted += ProcessStarted;
debugger.ProcessExited += ProcessExited;
debugger.DebuggingPaused += DebuggingPaused;
debugger.ExceptionThrown += ExceptionThrown;
debugger.DebuggeeStateChanged += DebuggeeStateChanged;
debugger.DebuggingResumed += DebuggingResumed;
@ -328,30 +329,31 @@ namespace ICSharpCode.SharpDevelop.Services @@ -328,30 +329,31 @@ namespace ICSharpCode.SharpDevelop.Services
}
}
void DebuggingPaused(object sender, DebuggingPausedEventArgs e)
void DebuggingPaused(object sender, DebuggerEventArgs e)
{
OnIsProcessRunningChanged(EventArgs.Empty);
}
void ExceptionThrown(object sender, ExceptionEventArgs e)
{
if (e.Exception.ExceptionType != ExceptionType.DEBUG_EXCEPTION_UNHANDLED) {
// Ignore the exception
e.Continue = true;
return;
}
JumpToCurrentLine();
if (e.Reason == PausedReason.Exception) {
if (debugger.SelectedThread.CurrentException.ExceptionType != ExceptionType.DEBUG_EXCEPTION_UNHANDLED) {
// Ignore the exception
e.ResumeDebuggingAfterEvent();
switch (ExceptionForm.Show(e.Exception)) {
case ExceptionForm.Result.Break:
break;
case ExceptionForm.Result.Continue:
e.Continue = true;
return;
}
JumpToCurrentLine();
switch (ExceptionForm.Show(debugger.SelectedThread.CurrentException)) {
case ExceptionForm.Result.Break:
break;
case ExceptionForm.Result.Continue:
e.ResumeDebuggingAfterEvent();
return;
case ExceptionForm.Result.Ignore:
debugger.SelectedThread.InterceptCurrentException();
e.ResumeDebuggingAfterEvent(); // HACK: Start interception
break;
}
case ExceptionForm.Result.Ignore:
debugger.SelectedThread.InterceptCurrentException();
e.Continue = true; // HACK: Start interception
break;
}
}

3
src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj

@ -50,8 +50,6 @@ @@ -50,8 +50,6 @@
<Compile Include="Src\Breakpoints\BreakpointEventArgs.cs" />
<Compile Include="Src\Breakpoints\NDebugger-Breakpoints.cs" />
<Compile Include="Src\Debugger\DebuggerEvents\DebuggerEventArgs.cs" />
<Compile Include="Src\Debugger\DebuggerEvents\DebuggingIsResumingEventArgs.cs" />
<Compile Include="Src\Debugger\DebuggerEvents\DebuggingPausedEventArgs.cs" />
<Compile Include="Src\Debugger\DebuggerEvents\MessageEventArgs.cs" />
<Compile Include="Src\Debugger\DebuggerEvents\PausedReason.cs" />
<Compile Include="Src\Debugger\Exceptions.cs" />
@ -384,6 +382,7 @@ @@ -384,6 +382,7 @@
<Compile Include="Src\Debugger\Util.cs" />
<Compile Include="Src\Variables\Evals\NewObjectEval.cs" />
<Compile Include="Src\Debugger\IMutable.cs" />
<Compile Include="Src\Debugger\ExceptionEventArgs.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="README.TXT" />

31
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/DebuggerEvents/DebuggingIsResumingEventArgs.cs

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace Debugger
{
[Serializable]
public class DebuggingIsResumingEventArgs : DebuggerEventArgs
{
bool abort;
public bool Abort {
get {
return abort;
}
set {
abort = value;
}
}
public DebuggingIsResumingEventArgs(NDebugger debugger): base(debugger)
{
this.abort = false;
}
}
}

47
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/DebuggerEvents/DebuggingPausedEventArgs.cs

@ -1,47 +0,0 @@ @@ -1,47 +0,0 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace Debugger
{
[Serializable]
public class DebuggingPausedEventArgs : DebuggerEventArgs
{
PausedReason reason;
bool resumeDebugging = false;
public PausedReason Reason {
get {
return reason;
}
}
internal bool ResumeDebugging {
get {
return resumeDebugging;
}
}
/// <summary>
/// Call this function to resume debugging when event is handled
///
/// This is prefered to calling Continue() since it ensures Continue is
/// called only once and never before all events are handled
/// </summary>
public void ResumeDebuggingAfterEvent()
{
resumeDebugging = true;
}
public DebuggingPausedEventArgs(NDebugger debugger, PausedReason reason): base(debugger)
{
this.reason = reason;
}
}
}

37
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/ExceptionEventArgs.cs

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/>
// <version>$Revision$</version>
// </file>
using System;
namespace Debugger
{
public class ExceptionEventArgs: DebuggerEventArgs
{
bool @continue;
Exception exception;
public bool Continue {
get {
return @continue;
}
set {
@continue = value;
}
}
public Exception Exception {
get {
return exception;
}
}
public ExceptionEventArgs(NDebugger debugger, Exception exception):base(debugger)
{
this.exception = exception;
}
}
}

14
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/MTA2STA.cs

@ -44,11 +44,17 @@ namespace Debugger @@ -44,11 +44,17 @@ namespace Debugger
void PerformAllCalls()
{
lock (pendingCalls) {
while (pendingCalls.Count > 0) {
pendingCalls.Dequeue()();
while (true) {
MethodInvoker nextMethod;
lock (pendingCalls) {
if (pendingCalls.Count > 0) {
nextMethod = pendingCalls.Dequeue();
} else {
pendingCallsNotEmpty.Reset();
return;
}
}
pendingCallsNotEmpty.Reset();
nextMethod();
}
}

8
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs

@ -100,14 +100,6 @@ namespace Debugger @@ -100,14 +100,6 @@ namespace Debugger
// Ignore events during property evaluation
ExitCallback_Continue();
} else {
if (debugger.SelectedThread != null) {
// Disable all steppers - do not Deactivate since function tracking still needs them
foreach(Stepper s in debugger.SelectedThread.Steppers) {
s.PauseWhenComplete = false;
}
debugger.SelectedThread.SelectedFunction = debugger.SelectedThread.LastFunctionWithLoadedSymbols;
}
debugger.Pause();
}
}

54
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger-StateControl.cs

@ -26,8 +26,9 @@ namespace Debugger @@ -26,8 +26,9 @@ namespace Debugger
Process selectedProcess;
public event EventHandler<ExceptionEventArgs> ExceptionThrown;
public event EventHandler<DebuggerEventArgs> DebuggingResumed;
public event EventHandler<DebuggingPausedEventArgs> DebuggingPaused;
public event EventHandler<DebuggerEventArgs> DebuggingPaused;
public event EventHandler<DebuggerEventArgs> DebuggeeStateChanged;
public bool PauseOnHandledException {
@ -39,6 +40,13 @@ namespace Debugger @@ -39,6 +40,13 @@ namespace Debugger
}
}
protected virtual void OnExceptionThrown(ExceptionEventArgs e)
{
if (ExceptionThrown != null) {
ExceptionThrown(this, e);
}
}
protected virtual void OnDebuggingResumed()
{
TraceMessage ("Debugger event: OnDebuggingResumed()");
@ -51,11 +59,7 @@ namespace Debugger @@ -51,11 +59,7 @@ namespace Debugger
{
TraceMessage ("Debugger event: OnDebuggingPaused (" + PausedReason.ToString() + ")");
if (DebuggingPaused != null) {
DebuggingPausedEventArgs args = new DebuggingPausedEventArgs(this, PausedReason);
DebuggingPaused(this, args);
if (args.ResumeDebugging) {
Continue();
}
DebuggingPaused(this, new DebuggerEventArgs(this));
}
}
@ -116,14 +120,6 @@ namespace Debugger @@ -116,14 +120,6 @@ namespace Debugger
get {
return debugeeState;
}
private set {
DebugeeState oldDebugeeState = debugeeState;
debugeeState = value;
OnDebuggeeStateChanged();
if (oldDebugeeState != null) {
oldDebugeeState.NotifyHasExpired();
}
}
}
public void AssertPaused()
@ -165,14 +161,36 @@ namespace Debugger @@ -165,14 +161,36 @@ namespace Debugger
internal void Pause()
{
if (PausedReason != PausedReason.EvalComplete) {
DebugeeState = new DebugeeState(this);
if (this.SelectedThread == null && this.Threads.Count > 0) {
this.SelectedProcess.SelectedThread = this.Threads[0];
}
OnDebuggingPaused();
if (this.SelectedThread != null) {
// Disable all steppers - do not Deactivate since function tracking still needs them
foreach(Stepper s in this.SelectedThread.Steppers) {
s.PauseWhenComplete = false;
}
this.SelectedThread.SelectedFunction = this.SelectedThread.LastFunctionWithLoadedSymbols;
}
if (PausedReason != PausedReason.EvalComplete) {
DebugeeState oldDebugeeState = debugeeState;
debugeeState = new DebugeeState(this);
OnDebuggeeStateChanged();
if (oldDebugeeState != null) {
oldDebugeeState.NotifyHasExpired();
}
}
OnDebuggingPaused();
if (PausedReason == PausedReason.Exception) {
ExceptionEventArgs args = new ExceptionEventArgs(this, SelectedThread.CurrentException);
OnExceptionThrown(args);
if (args.Continue) {
this.Continue();
}
}
// Debugger state is unknown after calling OnDebuggingPaused (it may be resumed)
if (IsPaused) {
pausedHandle.Set();
}

13
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs

@ -137,19 +137,6 @@ namespace Debugger @@ -137,19 +137,6 @@ namespace Debugger
debugger.PauseSession = new PauseSession(PausedReason.ForcedBreak);
debugger.SelectedProcess = this;
if (this.SelectedThread == null && this.Threads.Count > 0) {
this.SelectedThread = this.Threads[0];
}
if (debugger.SelectedThread != null) {
// Disable all steppers - do not Deactivate since function tracking still needs them
foreach(Stepper s in debugger.SelectedThread.Steppers) {
s.PauseWhenComplete = false;
}
debugger.SelectedThread.SelectedFunction = debugger.SelectedThread.LastFunctionWithLoadedSymbols;
}
debugger.Pause();
}

Loading…
Cancel
Save