Browse Source

Removed some silent fails. Bugfixing

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@67 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 22 years ago
parent
commit
886d53609f
  1. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs
  2. 13
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/MTA2STA.cs
  3. 8
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
  4. 38
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  5. 28
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs
  6. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  7. 42
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs
  8. 9
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs

2
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LocalVarPad.cs

@ -69,7 +69,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
val.Text = "Value"; val.Text = "Value";
type.Text = "Type"; type.Text = "Type";
if (NDebugger.IsProcessRunning == false) { if (NDebugger.IsDebugging && NDebugger.IsProcessRunning == false) {
debuggerService_OnDebuggingPaused(this, new DebuggingPausedEventArgs(PausedReason.StepComplete)); debuggerService_OnDebuggingPaused(this, new DebuggingPausedEventArgs(PausedReason.StepComplete));
} }
} }

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

@ -37,12 +37,6 @@ namespace DebuggerInterop.Core
System.Console.WriteLine("MTA2STA: " + msg); System.Console.WriteLine("MTA2STA: " + msg);
} }
void ErrorMsg(string msg)
{
System.Console.WriteLine("MTA2STA: ERROR: " + msg);
MessageBox.Show(msg);
}
public void CallInSTA (object targetObject, string functionName, object[] functionParameters) public void CallInSTA (object targetObject, string functionName, object[] functionParameters)
{ {
lock (OnlyOneAtTimeLock) { lock (OnlyOneAtTimeLock) {
@ -100,7 +94,9 @@ namespace DebuggerInterop.Core
try{ try{
outputParams[i] = null; outputParams[i] = null;
outputParams[i] = Marshal.GetTypedObjectForIUnknown((IntPtr)inputParams[i], outputParamsInfo[i].ParameterType); outputParams[i] = Marshal.GetTypedObjectForIUnknown((IntPtr)inputParams[i], outputParamsInfo[i].ParameterType);
}catch {} // TODO: Walkaround } catch (System.Exception exception) {
System.Diagnostics.Debug.Fail("Marshaling of argument " + i.ToString() + " of " + functionName + " failed.", exception.ToString());
}
} }
} else { } else {
outputParams[i] = inputParams[i]; outputParams[i] = inputParams[i];
@ -116,8 +112,7 @@ namespace DebuggerInterop.Core
method.Invoke(targetObject, outputParams); method.Invoke(targetObject, outputParams);
} }
} catch (System.Exception exception) { } catch (System.Exception exception) {
System.Diagnostics.Trace.WriteLine(exception.ToString()); System.Diagnostics.Debug.Fail("Invoke of " + functionName + " failed.", exception.ToString());
//System.Diagnostics.Debug.Fail("Invoke of " + functionName + " failed.", exception.ToString());
} }
TraceMsg ("} \\\\ Invoke"); TraceMsg ("} \\\\ Invoke");
} }

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

@ -236,7 +236,9 @@ namespace DebuggerLibrary
if (pThread != null) if (pThread != null)
{ {
EnterCallback("NameChange: pThread"); EnterCallback("NameChange: pThread");
NDebugger.Instance.GetThread(pThread).OnThreadStateChanged(); Thread thread = NDebugger.Instance.GetThread(pThread);
thread.HasBeenLoaded = true;
thread.OnThreadStateChanged();
ExitCallback_Continue(); ExitCallback_Continue();
return; return;
} }
@ -303,9 +305,7 @@ namespace DebuggerLibrary
NDebugger.Instance.RemoveThread(thread); NDebugger.Instance.RemoveThread(thread);
try { // TODO ExitCallback_Continue(pAppDomain);
ExitCallback_Continue(pAppDomain);
} catch {}
} }
public void ExitAppDomain(ICorDebugProcess pProcess, ICorDebugAppDomain pAppDomain) public void ExitAppDomain(ICorDebugProcess pProcess, ICorDebugAppDomain pAppDomain)

38
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs

@ -59,6 +59,7 @@ namespace DebuggerLibrary
try { try {
return CurrentThread.NextStatement; return CurrentThread.NextStatement;
} catch (CurrentThreadNotAviableException) { } catch (CurrentThreadNotAviableException) {
System.Diagnostics.Debug.Fail("Unable to get NextStatement. CurrentThreadNotAviableException");
throw new NextStatementNotAviableException(); throw new NextStatementNotAviableException();
} }
} }
@ -71,6 +72,7 @@ namespace DebuggerLibrary
thread = CurrentThread; thread = CurrentThread;
} }
catch (CurrentThreadNotAviableException) { catch (CurrentThreadNotAviableException) {
//System.Diagnostics.Debug.Fail("Unable to get LocalVariables. CurrentThreadNotAviableException");
return new VariableCollection (); return new VariableCollection ();
} }
return thread.LocalVariables; return thread.LocalVariables;
@ -313,7 +315,10 @@ namespace DebuggerLibrary
static public void Start(string filename, string workingDirectory, string arguments) static public void Start(string filename, string workingDirectory, string arguments)
{ {
if (IsDebugging) return; if (IsDebugging) {
System.Diagnostics.Debug.Fail("Invalid operation");
return;
}
m2s.CallInSTA(typeof(NDebugger), "StartInternal", new Object[] {filename, workingDirectory, arguments}); m2s.CallInSTA(typeof(NDebugger), "StartInternal", new Object[] {filename, workingDirectory, arguments});
return; return;
} }
@ -356,8 +361,10 @@ namespace DebuggerLibrary
static public void Break() static public void Break()
{ {
if (!IsDebugging) return; if (!IsDebugging || !IsProcessRunning) {
if (!IsProcessRunning) return; System.Diagnostics.Debug.Fail("Invalid operation");
return;
}
corProcess.Stop(5000); // TODO: Hardcoded value corProcess.Stop(5000); // TODO: Hardcoded value
@ -370,21 +377,27 @@ namespace DebuggerLibrary
{ {
try { try {
CurrentThread.StepInto(); CurrentThread.StepInto();
} catch (CurrentThreadNotAviableException) {} } catch (CurrentThreadNotAviableException) {
System.Diagnostics.Debug.Fail("Unable to prerform step. CurrentThreadNotAviableException");
}
} }
static public void StepOver() static public void StepOver()
{ {
try { try {
CurrentThread.StepOver(); CurrentThread.StepOver();
} catch (CurrentThreadNotAviableException) {} } catch (CurrentThreadNotAviableException) {
System.Diagnostics.Debug.Fail("Unable to prerform step. CurrentThreadNotAviableException");
}
} }
static public void StepOut() static public void StepOut()
{ {
try { try {
CurrentThread.StepOut(); CurrentThread.StepOut();
} catch (CurrentThreadNotAviableException) {} } catch (CurrentThreadNotAviableException) {
System.Diagnostics.Debug.Fail("Unable to prerform step. CurrentThreadNotAviableException");
}
} }
static internal void Continue(ICorDebugAppDomain pAppDomain) static internal void Continue(ICorDebugAppDomain pAppDomain)
@ -397,8 +410,10 @@ namespace DebuggerLibrary
static public void Continue() static public void Continue()
{ {
if (!IsDebugging) return; if (!IsDebugging || IsProcessRunning) {
if (IsProcessRunning) return; System.Diagnostics.Debug.Fail("Invalid operation");
return;
}
bool abort = false; bool abort = false;
OnDebuggingIsResuming(ref abort); OnDebuggingIsResuming(ref abort);
@ -415,7 +430,10 @@ namespace DebuggerLibrary
static public void Terminate() static public void Terminate()
{ {
if (!IsDebugging) return; if (!IsDebugging) {
System.Diagnostics.Debug.Fail("Invalid operation");
return;
}
int running; int running;
corProcess.IsRunning(out running); corProcess.IsRunning(out running);
@ -452,7 +470,7 @@ namespace DebuggerLibrary
foreach (Breakpoint breakpoint in Breakpoints) { foreach (Breakpoint breakpoint in Breakpoints) {
// TODO check filename too // TODO check filename too
if (breakpoint.SourcecodeSegment.StartLine == line) { if (breakpoint.SourcecodeSegment.StartLine == line) {
Breakpoints.Remove(breakpoint); RemoveBreakpoint(breakpoint);
return; return;
} }
} }

28
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs

@ -20,6 +20,8 @@ namespace DebuggerLibrary
ExceptionType exceptionType; ExceptionType exceptionType;
SourcecodeSegment location; SourcecodeSegment location;
DateTime creationTime; DateTime creationTime;
string type;
string message;
internal Exception(Thread thread) internal Exception(Thread thread)
{ {
@ -28,15 +30,23 @@ namespace DebuggerLibrary
thread.CorThread.GetCurrentException(out corValue); thread.CorThread.GetCurrentException(out corValue);
exceptionType = thread.CurrentExceptionType; exceptionType = thread.CurrentExceptionType;
runtimeVariable = VariableFactory.CreateVariable(corValue, "$exception"); runtimeVariable = VariableFactory.CreateVariable(corValue, "$exception");
runtimeVariableException = (ObjectVariable)runtimeVariable; runtimeVariableException = runtimeVariable as ObjectVariable;
while (runtimeVariableException.Type != "System.Exception") { if (runtimeVariableException != null) {
if (runtimeVariableException.HasBaseClass == false) { while (runtimeVariableException.Type != "System.Exception") {
runtimeVariableException = null; if (runtimeVariableException.HasBaseClass == false) {
break; runtimeVariableException = null;
break;
}
runtimeVariableException = runtimeVariableException.BaseClass;
} }
runtimeVariableException = runtimeVariableException.BaseClass; message = runtimeVariableException.SubVariables["_message"].Value.ToString();
} }
location = thread.NextStatement; try {
location = thread.NextStatement;
} catch (NextStatementNotAviableException) {
location = new SourcecodeSegment();
}
type = runtimeVariable.Type;
} }
public override string ToString() { public override string ToString() {
@ -47,13 +57,13 @@ namespace DebuggerLibrary
public string Type { public string Type {
get { get {
return runtimeVariable.Type; return type;
} }
} }
public string Message { public string Message {
get { get {
return runtimeVariableException.SubVariables["_message"].Value.ToString(); return message;
} }
} }

14
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs

@ -130,12 +130,16 @@ namespace DebuggerLibrary
private unsafe void Step(bool stepIn) private unsafe void Step(bool stepIn)
{ {
if (Module.SymbolsLoaded == false) return; if (Module.SymbolsLoaded == false) {
System.Diagnostics.Debug.Fail("Unable to step. No symbols loaded.");
return;
}
SourcecodeSegment nextSt; SourcecodeSegment nextSt;
try { try {
nextSt = NextStatement;// Cache nextSt = NextStatement;// Cache
} catch (NextStatementNotAviableException) { } catch (NextStatementNotAviableException) {
System.Diagnostics.Debug.Fail("Unable to step. Next statement not aviable");
return; return;
} }
@ -316,8 +320,12 @@ namespace DebuggerLibrary
} }
} }
} }
catch (FrameNotAviableException) {} catch (FrameNotAviableException) {
catch (SymbolsNotAviableException) {} System.Diagnostics.Debug.Fail("Unable to get local variables. Frame is not aviable");
}
catch (SymbolsNotAviableException) {
System.Diagnostics.Debug.Fail("Unable to get local variables. Symbols are not aviable");
}
return collection; return collection;
} }

42
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs

@ -20,9 +20,19 @@ namespace DebuggerLibrary
bool lastSuspendedState = false; bool lastSuspendedState = false;
ThreadPriority lastPriority = ThreadPriority.Normal; ThreadPriority lastPriority = ThreadPriority.Normal;
string lastName = string.Empty; string lastName = string.Empty;
bool hasBeenLoaded = false;
readonly ICorDebugThread corThread; readonly ICorDebugThread corThread;
internal bool HasBeenLoaded {
get {
return hasBeenLoaded;
}
set {
hasBeenLoaded = value;
}
}
public uint ID { public uint ID {
get{ get{
return id; return id;
@ -66,18 +76,20 @@ namespace DebuggerLibrary
public ThreadPriority Priority { public ThreadPriority Priority {
get { get {
if (!HasBeenLoaded) return lastPriority;
if (NDebugger.IsProcessRunning) return lastPriority; if (NDebugger.IsProcessRunning) return lastPriority;
Variable runTimeVar = runtimeVariable; Variable runTimeVar = RuntimeVariable;
if (runTimeVar is NullRefVariable) return ThreadPriority.Normal; if (runTimeVar is NullRefVariable) return ThreadPriority.Normal;
lastPriority = (ThreadPriority)(int)(runtimeVariable.SubVariables["m_Priority"] as BuiltInVariable).Value; lastPriority = (ThreadPriority)(int)(runTimeVar.SubVariables["m_Priority"] as BuiltInVariable).Value;
return lastPriority; return lastPriority;
} }
} }
public Variable runtimeVariable { public Variable RuntimeVariable {
get { get {
if (!HasBeenLoaded) throw new UnableToGetPropertyException(this, "runtimeVariable", "Thread has not started jet");
if (NDebugger.IsProcessRunning) throw new UnableToGetPropertyException(this, "runtimeVariable", "Process is running"); if (NDebugger.IsProcessRunning) throw new UnableToGetPropertyException(this, "runtimeVariable", "Process is running");
ICorDebugValue corValue; ICorDebugValue corValue;
corThread.GetObject(out corValue); corThread.GetObject(out corValue);
@ -88,8 +100,9 @@ namespace DebuggerLibrary
public string Name { public string Name {
get { get {
if (!HasBeenLoaded) return lastName;
if (NDebugger.IsProcessRunning) return lastName; if (NDebugger.IsProcessRunning) return lastName;
Variable runtimeVar = runtimeVariable; Variable runtimeVar = RuntimeVariable;
if (runtimeVar is NullRefVariable) return lastName; if (runtimeVar is NullRefVariable) return lastName;
Variable runtimeName = runtimeVar.SubVariables["m_Name"]; Variable runtimeName = runtimeVar.SubVariables["m_Name"];
if (runtimeName is NullRefVariable) return string.Empty; if (runtimeName is NullRefVariable) return string.Empty;
@ -124,7 +137,7 @@ namespace DebuggerLibrary
get { get {
List<Function> callstack = new List<Function>(); List<Function> callstack = new List<Function>();
if (!NDebugger.IsDebugging) return callstack; if (!NDebugger.IsDebugging) return callstack;
if (NDebugger.IsProcessRunning) return callstack; if (NDebugger.IsProcessRunning) return callstack;
ICorDebugChainEnum corChainEnum; ICorDebugChainEnum corChainEnum;
@ -153,7 +166,9 @@ namespace DebuggerLibrary
try { try {
callstack.Add(new Function(corFrames[0])); callstack.Add(new Function(corFrames[0]));
} }
catch (COMException) {}; catch (COMException) {
//System.Diagnostics.Debug.Fail("Error during adding function to callstack");
};
} }
} // for(;;) } // for(;;)
return callstack; return callstack;
@ -181,21 +196,27 @@ namespace DebuggerLibrary
{ {
try { try {
CurrentFunction.StepInto(); CurrentFunction.StepInto();
} catch (CurrentFunctionNotAviableException) {} } catch (CurrentFunctionNotAviableException) {
System.Diagnostics.Debug.Fail("Unable to prerform step. CurrentFunctionNotAviableException");
}
} }
public void StepOver() public void StepOver()
{ {
try { try {
CurrentFunction.StepOver(); CurrentFunction.StepOver();
} catch (CurrentFunctionNotAviableException) {} } catch (CurrentFunctionNotAviableException) {
System.Diagnostics.Debug.Fail("Unable to prerform step. CurrentFunctionNotAviableException");
}
} }
public void StepOut() public void StepOut()
{ {
try { try {
CurrentFunction.StepOut(); CurrentFunction.StepOut();
} catch (CurrentFunctionNotAviableException) {} } catch (CurrentFunctionNotAviableException) {
System.Diagnostics.Debug.Fail("Unable to prerform step. CurrentFunctionNotAviableException");
}
} }
public SourcecodeSegment NextStatement { public SourcecodeSegment NextStatement {
@ -208,7 +229,8 @@ namespace DebuggerLibrary
get { get {
try { try {
return CurrentFunction.LocalVariables; return CurrentFunction.LocalVariables;
} catch (NotAviableException) { } catch (NotAviableException exception) {
System.Diagnostics.Debug.Fail("Unable to get LocalVariables." + exception.ToString());
return new VariableCollection(); return new VariableCollection();
} }
} }

9
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableCollection.cs

@ -15,8 +15,9 @@ namespace DebuggerLibrary
internal void Add(Variable variable) internal void Add(Variable variable)
{ {
System.Diagnostics.Trace.Assert(variable != null); System.Diagnostics.Trace.Assert(variable != null);
if (variable != null) if (variable != null) {
InnerList.Add(variable); InnerList.Add(variable);
}
} }
public Variable this[int index] { public Variable this[int index] {
@ -28,9 +29,11 @@ namespace DebuggerLibrary
public Variable this[string variableName] public Variable this[string variableName]
{ {
get { get {
foreach (Variable v in InnerList) foreach (Variable v in InnerList) {
if (v.Name == variableName) if (v.Name == variableName) {
return v; return v;
}
}
throw new UnableToGetPropertyException(this, "this[string]", "Variable \"" + variableName + "\" is not in collection"); throw new UnableToGetPropertyException(this, "this[string]", "Variable \"" + variableName + "\" is not in collection");
} }

Loading…
Cancel
Save