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ý 21 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 @@ -69,7 +69,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
val.Text = "Value";
type.Text = "Type";
if (NDebugger.IsProcessRunning == false) {
if (NDebugger.IsDebugging && NDebugger.IsProcessRunning == false) {
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 @@ -37,12 +37,6 @@ namespace DebuggerInterop.Core
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)
{
lock (OnlyOneAtTimeLock) {
@ -100,7 +94,9 @@ namespace DebuggerInterop.Core @@ -100,7 +94,9 @@ namespace DebuggerInterop.Core
try{
outputParams[i] = null;
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 {
outputParams[i] = inputParams[i];
@ -116,8 +112,7 @@ namespace DebuggerInterop.Core @@ -116,8 +112,7 @@ namespace DebuggerInterop.Core
method.Invoke(targetObject, outputParams);
}
} 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");
}

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

@ -236,7 +236,9 @@ namespace DebuggerLibrary @@ -236,7 +236,9 @@ namespace DebuggerLibrary
if (pThread != null)
{
EnterCallback("NameChange: pThread");
NDebugger.Instance.GetThread(pThread).OnThreadStateChanged();
Thread thread = NDebugger.Instance.GetThread(pThread);
thread.HasBeenLoaded = true;
thread.OnThreadStateChanged();
ExitCallback_Continue();
return;
}
@ -303,9 +305,7 @@ namespace DebuggerLibrary @@ -303,9 +305,7 @@ namespace DebuggerLibrary
NDebugger.Instance.RemoveThread(thread);
try { // TODO
ExitCallback_Continue(pAppDomain);
} catch {}
ExitCallback_Continue(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 @@ -59,6 +59,7 @@ namespace DebuggerLibrary
try {
return CurrentThread.NextStatement;
} catch (CurrentThreadNotAviableException) {
System.Diagnostics.Debug.Fail("Unable to get NextStatement. CurrentThreadNotAviableException");
throw new NextStatementNotAviableException();
}
}
@ -71,6 +72,7 @@ namespace DebuggerLibrary @@ -71,6 +72,7 @@ namespace DebuggerLibrary
thread = CurrentThread;
}
catch (CurrentThreadNotAviableException) {
//System.Diagnostics.Debug.Fail("Unable to get LocalVariables. CurrentThreadNotAviableException");
return new VariableCollection ();
}
return thread.LocalVariables;
@ -313,7 +315,10 @@ namespace DebuggerLibrary @@ -313,7 +315,10 @@ namespace DebuggerLibrary
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});
return;
}
@ -356,8 +361,10 @@ namespace DebuggerLibrary @@ -356,8 +361,10 @@ namespace DebuggerLibrary
static public void Break()
{
if (!IsDebugging) return;
if (!IsProcessRunning) return;
if (!IsDebugging || !IsProcessRunning) {
System.Diagnostics.Debug.Fail("Invalid operation");
return;
}
corProcess.Stop(5000); // TODO: Hardcoded value
@ -370,21 +377,27 @@ namespace DebuggerLibrary @@ -370,21 +377,27 @@ namespace DebuggerLibrary
{
try {
CurrentThread.StepInto();
} catch (CurrentThreadNotAviableException) {}
} catch (CurrentThreadNotAviableException) {
System.Diagnostics.Debug.Fail("Unable to prerform step. CurrentThreadNotAviableException");
}
}
static public void StepOver()
{
try {
CurrentThread.StepOver();
} catch (CurrentThreadNotAviableException) {}
} catch (CurrentThreadNotAviableException) {
System.Diagnostics.Debug.Fail("Unable to prerform step. CurrentThreadNotAviableException");
}
}
static public void StepOut()
{
try {
CurrentThread.StepOut();
} catch (CurrentThreadNotAviableException) {}
} catch (CurrentThreadNotAviableException) {
System.Diagnostics.Debug.Fail("Unable to prerform step. CurrentThreadNotAviableException");
}
}
static internal void Continue(ICorDebugAppDomain pAppDomain)
@ -397,8 +410,10 @@ namespace DebuggerLibrary @@ -397,8 +410,10 @@ namespace DebuggerLibrary
static public void Continue()
{
if (!IsDebugging) return;
if (IsProcessRunning) return;
if (!IsDebugging || IsProcessRunning) {
System.Diagnostics.Debug.Fail("Invalid operation");
return;
}
bool abort = false;
OnDebuggingIsResuming(ref abort);
@ -415,7 +430,10 @@ namespace DebuggerLibrary @@ -415,7 +430,10 @@ namespace DebuggerLibrary
static public void Terminate()
{
if (!IsDebugging) return;
if (!IsDebugging) {
System.Diagnostics.Debug.Fail("Invalid operation");
return;
}
int running;
corProcess.IsRunning(out running);
@ -452,7 +470,7 @@ namespace DebuggerLibrary @@ -452,7 +470,7 @@ namespace DebuggerLibrary
foreach (Breakpoint breakpoint in Breakpoints) {
// TODO check filename too
if (breakpoint.SourcecodeSegment.StartLine == line) {
Breakpoints.Remove(breakpoint);
RemoveBreakpoint(breakpoint);
return;
}
}

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

@ -20,6 +20,8 @@ namespace DebuggerLibrary @@ -20,6 +20,8 @@ namespace DebuggerLibrary
ExceptionType exceptionType;
SourcecodeSegment location;
DateTime creationTime;
string type;
string message;
internal Exception(Thread thread)
{
@ -28,15 +30,23 @@ namespace DebuggerLibrary @@ -28,15 +30,23 @@ namespace DebuggerLibrary
thread.CorThread.GetCurrentException(out corValue);
exceptionType = thread.CurrentExceptionType;
runtimeVariable = VariableFactory.CreateVariable(corValue, "$exception");
runtimeVariableException = (ObjectVariable)runtimeVariable;
while (runtimeVariableException.Type != "System.Exception") {
if (runtimeVariableException.HasBaseClass == false) {
runtimeVariableException = null;
break;
runtimeVariableException = runtimeVariable as ObjectVariable;
if (runtimeVariableException != null) {
while (runtimeVariableException.Type != "System.Exception") {
if (runtimeVariableException.HasBaseClass == false) {
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() {
@ -47,13 +57,13 @@ namespace DebuggerLibrary @@ -47,13 +57,13 @@ namespace DebuggerLibrary
public string Type {
get {
return runtimeVariable.Type;
return type;
}
}
public string Message {
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 @@ -130,12 +130,16 @@ namespace DebuggerLibrary
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;
try {
nextSt = NextStatement;// Cache
} catch (NextStatementNotAviableException) {
System.Diagnostics.Debug.Fail("Unable to step. Next statement not aviable");
return;
}
@ -316,8 +320,12 @@ namespace DebuggerLibrary @@ -316,8 +320,12 @@ namespace DebuggerLibrary
}
}
}
catch (FrameNotAviableException) {}
catch (SymbolsNotAviableException) {}
catch (FrameNotAviableException) {
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;
}

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

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

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

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

Loading…
Cancel
Save