Browse Source

Debugger made less static 2

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@174 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 21 years ago
parent
commit
809b9fd96c
  1. 4
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/BreakPointsPad.cs
  2. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LoadedModulesPad.cs
  3. 2
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/RunningThreadsPad.cs
  4. 6
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  5. 23
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/Breakpoint.cs
  6. 8
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/NDebugger-Breakpoints.cs
  7. 7
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
  8. 24
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  9. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Exception.cs
  10. 17
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  11. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Threads.cs
  12. 41
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs
  13. 31
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs
  14. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayVariable.cs
  15. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/BuiltInVariable.cs
  16. 13
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs
  17. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/EvalQueue.cs
  18. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullRefVariable.cs
  19. 10
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectVariable.cs
  20. 4
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs
  21. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnknownVariable.cs
  22. 5
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs
  23. 12
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableFactory.cs

4
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/BreakPointsPad.cs

@ -92,7 +92,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -92,7 +92,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
breakpointsList.ItemCheck -= new ItemCheckEventHandler(BreakpointsListItemCheck);
breakpointsList.BeginUpdate();
breakpointsList.Items.Clear();
foreach(DebuggerLibrary.Breakpoint b in NDebugger.Instance.Breakpoints) {
foreach(DebuggerLibrary.Breakpoint b in debugger.Breakpoints) {
AddBreakpoint(new BreakpointEventArgs(b));
}
breakpointsList.EndUpdate();
@ -157,7 +157,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -157,7 +157,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
void debuggerService_OnDebuggingResumed(object sender, DebuggerEventArgs e)
{
breakpointsList.BeginUpdate();
foreach(DebuggerLibrary.Breakpoint b in NDebugger.Instance.Breakpoints)
foreach(DebuggerLibrary.Breakpoint b in debugger.Breakpoints)
RefreshBreakpoint(this, new BreakpointEventArgs(b));
breakpointsList.EndUpdate();
}

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

@ -87,7 +87,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -87,7 +87,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
information.Text = StringParser.Parse("${res:MainWindow.Windows.Debug.InformationColumn}");
loadedModulesList.Items.Clear();
foreach(Module m in NDebugger.Instance.Modules) {
foreach(Module m in debugger.Modules) {
AddModule(this, new ModuleEventArgs(m));
}
}

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

@ -134,7 +134,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -134,7 +134,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
private void RefreshAllItems()
{
foreach (Thread t in NDebugger.Instance.Threads) {
foreach (Thread t in debugger.Threads) {
RefreshThread(this, new ThreadEventArgs(t));
}
}

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

@ -134,12 +134,12 @@ namespace ICSharpCode.SharpDevelop.Services @@ -134,12 +134,12 @@ namespace ICSharpCode.SharpDevelop.Services
public void RestoreNDebuggerBreakpoints(object sender, EventArgs e)
{
NDebugger.Instance.ClearBreakpoints();
ClearBreakpoints();
foreach (ICSharpCode.Core.Breakpoint b in DebuggerService.Breakpoints) {
DebuggerLibrary.Breakpoint newBreakpoint = new DebuggerLibrary.Breakpoint(b.FileName, b.LineNumber, 0, b.IsEnabled);
DebuggerLibrary.Breakpoint newBreakpoint = new DebuggerLibrary.Breakpoint(this, b.FileName, b.LineNumber, 0, b.IsEnabled);
newBreakpoint.Tag = b;
b.Tag = newBreakpoint;
NDebugger.Instance.AddBreakpoint(newBreakpoint);
AddBreakpoint(newBreakpoint);
}
}

23
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/Breakpoint.cs

@ -13,6 +13,8 @@ namespace DebuggerLibrary @@ -13,6 +13,8 @@ namespace DebuggerLibrary
{
public class Breakpoint
{
NDebugger debugger;
readonly SourcecodeSegment sourcecodeSegment;
bool hadBeenSet = false;
@ -82,34 +84,39 @@ namespace DebuggerLibrary @@ -82,34 +84,39 @@ namespace DebuggerLibrary
BreakpointHit(this, new BreakpointEventArgs(this));
}
public Breakpoint(SourcecodeSegment segment)
public Breakpoint(NDebugger debugger, SourcecodeSegment segment)
{
this.debugger = debugger;
sourcecodeSegment = segment;
}
public Breakpoint(int line)
public Breakpoint(NDebugger debugger, int line)
{
this.debugger = debugger;
sourcecodeSegment = new SourcecodeSegment();
sourcecodeSegment.StartLine = line;
}
public Breakpoint(string sourceFilename, int line)
public Breakpoint(NDebugger debugger, string sourceFilename, int line)
{
this.debugger = debugger;
sourcecodeSegment = new SourcecodeSegment();
sourcecodeSegment.SourceFullFilename = sourceFilename;
sourcecodeSegment.StartLine = line;
}
public Breakpoint(string sourceFilename, int line, int column)
public Breakpoint(NDebugger debugger, string sourceFilename, int line, int column)
{
this.debugger = debugger;
sourcecodeSegment = new SourcecodeSegment();
sourcecodeSegment.SourceFullFilename = sourceFilename;
sourcecodeSegment.StartLine = line;
sourcecodeSegment.StartColumn = column;
}
public Breakpoint(string sourceFilename, int line, int column, bool enabled)
public Breakpoint(NDebugger debugger, string sourceFilename, int line, int column, bool enabled)
{
this.debugger = debugger;
sourcecodeSegment = new SourcecodeSegment();
sourcecodeSegment.SourceFullFilename = sourceFilename;
sourcecodeSegment.StartLine = line;
@ -161,8 +168,8 @@ namespace DebuggerLibrary @@ -161,8 +168,8 @@ namespace DebuggerLibrary
{
try
{
module = NDebugger.Instance.GetModule(seg.ModuleFilename);
symReader = NDebugger.Instance.GetModule(seg.ModuleFilename).SymReader;
module = debugger.GetModule(seg.ModuleFilename);
symReader = debugger.GetModule(seg.ModuleFilename).SymReader;
symDoc = symReader.GetDocument(seg.SourceFullFilename,Guid.Empty,Guid.Empty,Guid.Empty);
}
catch {}
@ -170,7 +177,7 @@ namespace DebuggerLibrary @@ -170,7 +177,7 @@ namespace DebuggerLibrary
// search all modules
if (symDoc == null) {
foreach (Module m in NDebugger.Instance.Modules) {
foreach (Module m in debugger.Modules) {
module = m;
symReader = m.SymReader;
if (symReader == null) {

8
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/NDebugger-Breakpoints.cs

@ -80,22 +80,22 @@ namespace DebuggerLibrary @@ -80,22 +80,22 @@ namespace DebuggerLibrary
public Breakpoint AddBreakpoint(SourcecodeSegment segment)
{
return AddBreakpoint(new Breakpoint(segment));
return AddBreakpoint(new Breakpoint(this, segment));
}
public Breakpoint AddBreakpoint(int line)
{
return AddBreakpoint(new Breakpoint(line));
return AddBreakpoint(new Breakpoint(this, line));
}
public Breakpoint AddBreakpoint(string sourceFilename, int line)
{
return AddBreakpoint(new Breakpoint(sourceFilename, line));
return AddBreakpoint(new Breakpoint(this, sourceFilename, line));
}
public Breakpoint AddBreakpoint(string sourceFilename, int line, int column)
{
return AddBreakpoint(new Breakpoint(sourceFilename, line, column));
return AddBreakpoint(new Breakpoint(this, sourceFilename, line, column));
}
public void RemoveBreakpoint(Breakpoint breakpoint)

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

@ -18,10 +18,15 @@ namespace DebuggerLibrary @@ -18,10 +18,15 @@ namespace DebuggerLibrary
{
class ManagedCallback
{
NDebugger debugger = NDebugger.Instance;
NDebugger debugger;
bool handlingCallback = false;
public event CorDebugEvalEventHandler CorDebugEvalCompleted;
public ManagedCallback(NDebugger debugger)
{
this.debugger = debugger;
}
public bool HandlingCallback {
get {

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

@ -15,20 +15,6 @@ namespace DebuggerLibrary @@ -15,20 +15,6 @@ namespace DebuggerLibrary
{
public partial class NDebugger
{
static NDebugger instance = null;
public static NDebugger Instance {
get {
if (instance == null) {
throw new System.Exception("Create instance of NDebugger first");
}
return instance;
}
set {
instance = value;
}
}
ICorDebug corDebug;
ManagedCallback managedCallback;
ManagedCallbackProxy managedCallbackProxy;
@ -74,12 +60,6 @@ namespace DebuggerLibrary @@ -74,12 +60,6 @@ namespace DebuggerLibrary
public NDebugger()
{
if (instance != null) {
throw new System.Exception("You can create only one instance of NDebugger at the moment.");
} else {
instance = this;
}
InitDebugger();
ResetEnvironment();
@ -101,7 +81,7 @@ namespace DebuggerLibrary @@ -101,7 +81,7 @@ namespace DebuggerLibrary
NativeMethods.CreateDebuggingInterfaceFromVersion(3, sb.ToString(), out corDebug);
//corDebug = new CorDebugClass();
managedCallback = new ManagedCallback();
managedCallback = new ManagedCallback(this);
managedCallbackProxy = new ManagedCallbackProxy(managedCallback);
corDebug.Initialize();
@ -262,7 +242,7 @@ namespace DebuggerLibrary @@ -262,7 +242,7 @@ namespace DebuggerLibrary
public void Start(string filename, string workingDirectory, string arguments)
{
CurrentProcess = Process.CreateProcess(filename, workingDirectory, arguments);
CurrentProcess = Process.CreateProcess(this, filename, workingDirectory, arguments);
}

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

@ -13,6 +13,7 @@ namespace DebuggerLibrary @@ -13,6 +13,7 @@ namespace DebuggerLibrary
{
public class Exception
{
NDebugger debugger;
Thread thread;
ICorDebugValue corValue;
Variable runtimeVariable;
@ -23,13 +24,14 @@ namespace DebuggerLibrary @@ -23,13 +24,14 @@ namespace DebuggerLibrary
string type;
string message;
internal Exception(Thread thread)
internal Exception(NDebugger debugger, Thread thread)
{
creationTime = DateTime.Now;
this.debugger = debugger;
this.thread = thread;
thread.CorThread.GetCurrentException(out corValue);
exceptionType = thread.CurrentExceptionType;
runtimeVariable = VariableFactory.CreateVariable(corValue, "$exception");
runtimeVariable = VariableFactory.CreateVariable(debugger, corValue, "$exception");
runtimeVariableException = runtimeVariable as ObjectVariable;
if (runtimeVariableException != null) {
while (runtimeVariableException.Type != "System.Exception") {

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

@ -16,6 +16,8 @@ namespace DebuggerLibrary @@ -16,6 +16,8 @@ namespace DebuggerLibrary
{
public class Function
{
NDebugger debugger;
string name;
Module module;
SymbolToken token;
@ -36,8 +38,9 @@ namespace DebuggerLibrary @@ -36,8 +38,9 @@ namespace DebuggerLibrary
}
}
internal unsafe Function(ICorDebugFrame corFrame)
internal unsafe Function(NDebugger debugger, ICorDebugFrame corFrame)
{
this.debugger = debugger;
this.corFrame = corFrame;
corFrame.GetFunction(out corFunction);
uint functionToken;
@ -45,7 +48,7 @@ namespace DebuggerLibrary @@ -45,7 +48,7 @@ namespace DebuggerLibrary
this.token = new SymbolToken((int)functionToken);
ICorDebugModule corModule;
corFunction.GetModule(out corModule);
module = NDebugger.Instance.GetModule(corModule);
module = debugger.GetModule(corModule);
Init();
}
@ -144,7 +147,7 @@ namespace DebuggerLibrary @@ -144,7 +147,7 @@ namespace DebuggerLibrary
corFrame.CreateStepper(out stepper);
stepper.StepOut();
NDebugger.Instance.Continue();
debugger.Continue();
}
private unsafe void Step(bool stepIn)
@ -169,7 +172,7 @@ namespace DebuggerLibrary @@ -169,7 +172,7 @@ namespace DebuggerLibrary
stepper.StepRange(stepIn?1:0, (IntPtr)ranges, (uint)nextSt.StepRanges.Length / 2);
}
NDebugger.Instance.Continue();
debugger.Continue();
}
/// <summary>
@ -305,7 +308,7 @@ namespace DebuggerLibrary @@ -305,7 +308,7 @@ namespace DebuggerLibrary
if (!isStatic) {
corILFrame.GetArgument(0, out argThis);
}
collection = new ObjectVariable(argThis, "this", corClass).SubVariables;
collection = new ObjectVariable(debugger, argThis, "this", corClass).SubVariables;
// arguments
ICorDebugValueEnum corValueEnum;
@ -354,7 +357,7 @@ namespace DebuggerLibrary @@ -354,7 +357,7 @@ namespace DebuggerLibrary
string name = Marshal.PtrToStringUni(pString);
Marshal.FreeHGlobal(pString);
collection.Add(VariableFactory.CreateVariable(arg, name));
collection.Add(VariableFactory.CreateVariable(debugger, arg, name));
}
// local variables
@ -430,7 +433,7 @@ namespace DebuggerLibrary @@ -430,7 +433,7 @@ namespace DebuggerLibrary
{
ICorDebugValue runtimeVar;
corILFrame.GetLocalVariable((uint)symVar.AddressField1, out runtimeVar);
collection.Add(VariableFactory.CreateVariable(runtimeVar, symVar.Name));
collection.Add(VariableFactory.CreateVariable(debugger, runtimeVar, symVar.Name));
}
}
}

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Threads.cs

@ -64,7 +64,7 @@ namespace DebuggerLibrary @@ -64,7 +64,7 @@ namespace DebuggerLibrary
internal void AddThread(ICorDebugThread corThread)
{
AddThread(new Thread(corThread));
AddThread(new Thread(this, corThread));
}
internal void RemoveThread(Thread thread)

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

@ -14,14 +14,17 @@ namespace DebuggerLibrary @@ -14,14 +14,17 @@ namespace DebuggerLibrary
{
public class Process
{
ICorDebugProcess corProcess;
NDebugger debugger;
Thread mainThread;
Thread currentThread;
bool isProcessRunning;
ICorDebugProcess corProcess;
internal Process(ICorDebugProcess corProcess)
Thread mainThread;
Thread currentThread;
bool isProcessRunning;
internal Process(NDebugger debugger, ICorDebugProcess corProcess)
{
this.debugger = debugger;
this.corProcess = corProcess;
}
@ -43,8 +46,8 @@ namespace DebuggerLibrary @@ -43,8 +46,8 @@ namespace DebuggerLibrary
if (mainThread == null) {
mainThread = value;
}
if (NDebugger.Instance.ManagedCallback.HandlingCallback == false) {
NDebugger.Instance.OnDebuggingPaused(PausedReason.CurrentThreadChanged);
if (debugger.ManagedCallback.HandlingCallback == false) {
debugger.OnDebuggingPaused(PausedReason.CurrentThreadChanged);
}
}
}
@ -83,17 +86,17 @@ namespace DebuggerLibrary @@ -83,17 +86,17 @@ namespace DebuggerLibrary
}
}
static public Process CreateProcess(string filename, string workingDirectory, string arguments)
static public Process CreateProcess(NDebugger debugger, string filename, string workingDirectory, string arguments)
{
MTA2STA m2s = new MTA2STA();
Process createdProcess = null;
createdProcess = (Process)m2s.CallInSTA(typeof(Process), "StartInternal", new Object[] {filename, workingDirectory, arguments});
createdProcess = (Process)m2s.CallInSTA(typeof(Process), "StartInternal", new Object[] {debugger, filename, workingDirectory, arguments});
return createdProcess;
}
static public unsafe Process StartInternal(string filename, string workingDirectory, string arguments)
static public unsafe Process StartInternal(NDebugger debugger, string filename, string workingDirectory, string arguments)
{
NDebugger.Instance.TraceMessage("Executing " + filename);
debugger.TraceMessage("Executing " + filename);
_SECURITY_ATTRIBUTES secAttr = new _SECURITY_ATTRIBUTES();
secAttr.bInheritHandle = 0;
@ -108,7 +111,7 @@ namespace DebuggerLibrary @@ -108,7 +111,7 @@ namespace DebuggerLibrary
fixed (uint* pprocessStartupInfo = processStartupInfo)
fixed (uint* pprocessInfo = processInfo)
NDebugger.Instance.CorDebug.CreateProcess(
debugger.CorDebug.CreateProcess(
filename, // lpApplicationName
arguments, // lpCommandLine
ref secAttr, // lpProcessAttributes
@ -123,7 +126,7 @@ namespace DebuggerLibrary @@ -123,7 +126,7 @@ namespace DebuggerLibrary
out outProcess // ppProcess
);
return new Process(outProcess);
return new Process(debugger, outProcess);
}
public void Break()
@ -136,8 +139,8 @@ namespace DebuggerLibrary @@ -136,8 +139,8 @@ namespace DebuggerLibrary
corProcess.Stop(5000); // TODO: Hardcoded value
isProcessRunning = false;
NDebugger.Instance.OnDebuggingPaused(PausedReason.Break);
NDebugger.Instance.OnIsProcessRunningChanged();
debugger.OnDebuggingPaused(PausedReason.Break);
debugger.OnIsProcessRunningChanged();
}
public void StepInto()
@ -175,13 +178,13 @@ namespace DebuggerLibrary @@ -175,13 +178,13 @@ namespace DebuggerLibrary
}
bool abort = false;
NDebugger.Instance.OnDebuggingIsResuming(ref abort);
debugger.OnDebuggingIsResuming(ref abort);
if (abort == true) return;
isProcessRunning = true;
if (NDebugger.Instance.ManagedCallback.HandlingCallback == false) {
NDebugger.Instance.OnDebuggingResumed();
NDebugger.Instance.OnIsProcessRunningChanged();
if (debugger.ManagedCallback.HandlingCallback == false) {
debugger.OnDebuggingResumed();
debugger.OnIsProcessRunningChanged();
}
corProcess.Continue(0);

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

@ -14,6 +14,10 @@ namespace DebuggerLibrary @@ -14,6 +14,10 @@ namespace DebuggerLibrary
{
public partial class Thread
{
NDebugger debugger;
ICorDebugThread corThread;
internal ExceptionType currentExceptionType;
uint id;
@ -21,8 +25,6 @@ namespace DebuggerLibrary @@ -21,8 +25,6 @@ namespace DebuggerLibrary
ThreadPriority lastPriority = ThreadPriority.Normal;
string lastName = string.Empty;
bool hasBeenLoaded = false;
readonly ICorDebugThread corThread;
internal bool HasBeenLoaded {
get {
@ -54,15 +56,16 @@ namespace DebuggerLibrary @@ -54,15 +56,16 @@ namespace DebuggerLibrary
}
}
internal Thread(ICorDebugThread corThread)
internal Thread(NDebugger debugger, ICorDebugThread corThread)
{
this.debugger = debugger;
this.corThread = corThread;
corThread.GetID(out id);
}
public bool Suspended {
get {
if (NDebugger.Instance.IsProcessRunning) return lastSuspendedState;
if (debugger.IsProcessRunning) return lastSuspendedState;
CorDebugThreadState state;
corThread.GetDebugState(out state);
@ -77,7 +80,7 @@ namespace DebuggerLibrary @@ -77,7 +80,7 @@ namespace DebuggerLibrary
public ThreadPriority Priority {
get {
if (!HasBeenLoaded) return lastPriority;
if (NDebugger.Instance.IsProcessRunning) return lastPriority;
if (debugger.IsProcessRunning) return lastPriority;
Variable runTimeVar = RuntimeVariable;
if (runTimeVar is NullRefVariable) return ThreadPriority.Normal;
@ -90,10 +93,10 @@ namespace DebuggerLibrary @@ -90,10 +93,10 @@ namespace DebuggerLibrary
public Variable RuntimeVariable {
get {
if (!HasBeenLoaded) throw new UnableToGetPropertyException(this, "runtimeVariable", "Thread has not started jet");
if (NDebugger.Instance.IsProcessRunning) throw new UnableToGetPropertyException(this, "runtimeVariable", "Process is running");
if (debugger.IsProcessRunning) throw new UnableToGetPropertyException(this, "runtimeVariable", "Process is running");
ICorDebugValue corValue;
corThread.GetObject(out corValue);
return VariableFactory.CreateVariable(corValue, "Thread" + ID);
return VariableFactory.CreateVariable(debugger, corValue, "Thread" + ID);
}
}
@ -101,7 +104,7 @@ namespace DebuggerLibrary @@ -101,7 +104,7 @@ namespace DebuggerLibrary
public string Name {
get {
if (!HasBeenLoaded) return lastName;
if (NDebugger.Instance.IsProcessRunning) return lastName;
if (debugger.IsProcessRunning) return lastName;
Variable runtimeVar = RuntimeVariable;
if (runtimeVar is NullRefVariable) return lastName;
Variable runtimeName = runtimeVar.SubVariables["m_Name"];
@ -129,7 +132,7 @@ namespace DebuggerLibrary @@ -129,7 +132,7 @@ namespace DebuggerLibrary
public Exception CurrentException {
get {
return new Exception(this);
return new Exception(debugger, this);
}
}
@ -137,8 +140,8 @@ namespace DebuggerLibrary @@ -137,8 +140,8 @@ namespace DebuggerLibrary
get {
List<Function> callstack = new List<Function>();
if (!NDebugger.Instance.IsDebugging) return callstack;
if (NDebugger.Instance.IsProcessRunning) return callstack;
if (!debugger.IsDebugging) return callstack;
if (debugger.IsProcessRunning) return callstack;
ICorDebugChainEnum corChainEnum;
corThread.EnumerateChains(out corChainEnum);
@ -164,7 +167,7 @@ namespace DebuggerLibrary @@ -164,7 +167,7 @@ namespace DebuggerLibrary
if (framesFetched == 0) break; // We are done
try {
callstack.Add(new Function(corFrames[0]));
callstack.Add(new Function(debugger, corFrames[0]));
}
catch (COMException) {
//System.Diagnostics.Debug.Fail("Error during adding function to callstack");
@ -177,7 +180,7 @@ namespace DebuggerLibrary @@ -177,7 +180,7 @@ namespace DebuggerLibrary
public Function CurrentFunction {
get {
if (NDebugger.Instance.IsProcessRunning) throw new CurrentFunctionNotAviableException();
if (debugger.IsProcessRunning) throw new CurrentFunctionNotAviableException();
ICorDebugFrame corFrame;
corThread.GetActiveFrame(out corFrame);
if (corFrame == null) {
@ -188,7 +191,7 @@ namespace DebuggerLibrary @@ -188,7 +191,7 @@ namespace DebuggerLibrary
throw new CurrentFunctionNotAviableException();
}
}
return new Function(corFrame);
return new Function(debugger, corFrame);
}
}

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ArrayVariable.cs

@ -51,7 +51,7 @@ namespace DebuggerLibrary @@ -51,7 +51,7 @@ namespace DebuggerLibrary
}
internal unsafe ArrayVariable(ICorDebugValue corValue, string name):base(corValue, name)
internal unsafe ArrayVariable(NDebugger debugger, ICorDebugValue corValue, string name):base(debugger, corValue, name)
{
corArrayValue = (ICorDebugArrayValue)this.corValue;
uint corElementTypeRaw;
@ -98,7 +98,7 @@ namespace DebuggerLibrary @@ -98,7 +98,7 @@ namespace DebuggerLibrary
fixed (void* pIndices = indices)
corArrayValue.GetElement(rank, new IntPtr(pIndices), out element);
return VariableFactory.CreateVariable(element, elementName);
return VariableFactory.CreateVariable(debugger, element, elementName);
}
}

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/BuiltInVariable.cs

@ -66,7 +66,7 @@ namespace DebuggerLibrary @@ -66,7 +66,7 @@ namespace DebuggerLibrary
}
}
internal BuiltInVariable(ICorDebugValue corValue, string name):base(corValue, name)
internal BuiltInVariable(NDebugger debugger, ICorDebugValue corValue, string name):base(debugger, corValue, name)
{
}
}

13
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/Eval.cs

@ -14,6 +14,8 @@ namespace DebuggerLibrary @@ -14,6 +14,8 @@ namespace DebuggerLibrary
{
class Eval
{
NDebugger debugger;
ICorDebugEval corEval;
ICorDebugFunction corFunction;
ICorDebugValue[] args;
@ -28,11 +30,12 @@ namespace DebuggerLibrary @@ -28,11 +30,12 @@ namespace DebuggerLibrary
}
}
public Eval(ICorDebugFunction corFunction, ICorDebugValue[] args)
public Eval(NDebugger debugger, ICorDebugFunction corFunction, ICorDebugValue[] args)
{
this.debugger = debugger;
this.corFunction = corFunction;
this.args = args;
NDebugger.Instance.ManagedCallback.CorDebugEvalCompleted += new CorDebugEvalEventHandler(CorDebugEvalCompleted);
debugger.ManagedCallback.CorDebugEvalCompleted += new CorDebugEvalEventHandler(CorDebugEvalCompleted);
}
/// <summary>
@ -53,15 +56,15 @@ namespace DebuggerLibrary @@ -53,15 +56,15 @@ namespace DebuggerLibrary
/// </summary>
public void AsyncPerformEval()
{
if (NDebugger.Instance.IsProcessRunning) {
if (debugger.IsProcessRunning) {
throw new DebuggerException("Debugger must be paused");
}
NDebugger.Instance.CurrentThread.CorThread.CreateEval(out corEval);
debugger.CurrentThread.CorThread.CreateEval(out corEval);
corEval.CallFunction(corFunction, (uint)args.Length, args);
NDebugger.Instance.Continue();
debugger.Continue();
}
public ICorDebugValue GetResult()

3
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Evals/EvalQueue.cs

@ -32,9 +32,6 @@ namespace DebuggerLibrary @@ -32,9 +32,6 @@ namespace DebuggerLibrary
static public void PerformNextEval()
{
if (NDebugger.Instance.IsProcessRunning) {
return;
}
if (waitingEvals.Count == 0) {
return;
}

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/NullRefVariable.cs

@ -33,7 +33,7 @@ namespace DebuggerLibrary @@ -33,7 +33,7 @@ namespace DebuggerLibrary
}
}
internal unsafe NullRefVariable(ICorDebugValue corValue, string name):base(corValue, name)
internal unsafe NullRefVariable(NDebugger debugger, ICorDebugValue corValue, string name):base(debugger, corValue, name)
{
}

10
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectVariable.cs

@ -38,13 +38,13 @@ namespace DebuggerLibrary @@ -38,13 +38,13 @@ namespace DebuggerLibrary
}
internal unsafe ObjectVariable(ICorDebugValue corValue, string name):base(corValue, name)
internal unsafe ObjectVariable(NDebugger debugger, ICorDebugValue corValue, string name):base(debugger, corValue, name)
{
((ICorDebugObjectValue)this.corValue).GetClass(out corClass);
InitObjectVariable();
}
internal unsafe ObjectVariable(ICorDebugValue corValue, string name, ICorDebugClass corClass):base(corValue, name)
internal unsafe ObjectVariable(NDebugger debugger, ICorDebugValue corValue, string name, ICorDebugClass corClass):base(debugger, corValue, name)
{
this.corClass = corClass;
InitObjectVariable();
@ -144,7 +144,7 @@ namespace DebuggerLibrary @@ -144,7 +144,7 @@ namespace DebuggerLibrary
((ICorDebugObjectValue)corValue).GetFieldValue(corClass, fieldToken, out innerValue);
}
subVariables.Add(VariableFactory.CreateVariable(innerValue, name));
subVariables.Add(VariableFactory.CreateVariable(debugger, innerValue, name));
}
return subVariables;
@ -193,7 +193,7 @@ namespace DebuggerLibrary @@ -193,7 +193,7 @@ namespace DebuggerLibrary
Marshal.FreeHGlobal(pString);
superCallsToken = 0;
foreach (Module m in NDebugger.Instance.Modules)
foreach (Module m in debugger.Modules)
{
// TODO: Does not work for nested
// see FindTypeDefByName in dshell.cpp
@ -219,7 +219,7 @@ namespace DebuggerLibrary @@ -219,7 +219,7 @@ namespace DebuggerLibrary
{
ICorDebugClass superClass;
corModuleSuperclass.GetClassFromToken(superCallsToken, out superClass);
return new ObjectVariable(corValue, Name, superClass);
return new ObjectVariable(debugger, corValue, Name, superClass);
}
}
}

4
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/PropertyVariable.cs

@ -14,7 +14,7 @@ namespace DebuggerLibrary @@ -14,7 +14,7 @@ namespace DebuggerLibrary
Variable currentValue;
public event EventHandler ValueEvaluated;
internal PropertyVariable(Eval eval, string name):base(null, name)
internal PropertyVariable(NDebugger debugger, Eval eval, string name):base(debugger, null, name)
{
this.eval = eval;
eval.EvalComplete += new EventHandler(EvalComplete);
@ -72,7 +72,7 @@ namespace DebuggerLibrary @@ -72,7 +72,7 @@ namespace DebuggerLibrary
void EvalComplete(object sender, EventArgs args)
{
currentValue = VariableFactory.CreateVariable(eval.GetResult(), Name);
currentValue = VariableFactory.CreateVariable(debugger, eval.GetResult(), Name);
OnValueEvaluated();
}

2
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/UnknownVariable.cs

@ -23,7 +23,7 @@ namespace DebuggerLibrary @@ -23,7 +23,7 @@ namespace DebuggerLibrary
}
}
internal unsafe UnknownVariable(ICorDebugValue corValue, string name):base(corValue, name)
internal unsafe UnknownVariable(NDebugger debugger, ICorDebugValue corValue, string name):base(debugger, corValue, name)
{
}

5
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/Variable.cs

@ -12,6 +12,8 @@ namespace DebuggerLibrary @@ -12,6 +12,8 @@ namespace DebuggerLibrary
{
public abstract class Variable
{
protected NDebugger debugger;
readonly string name;
protected ICorDebugValue corValue;
VariableCollection subVariables;
@ -50,8 +52,9 @@ namespace DebuggerLibrary @@ -50,8 +52,9 @@ namespace DebuggerLibrary
}
}
internal Variable(ICorDebugValue corValue, string name)
internal Variable(NDebugger debugger, ICorDebugValue corValue, string name)
{
this.debugger = debugger;
if (corValue != null) {
this.corValue = DereferenceUnbox(corValue);
}

12
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/VariableFactory.cs

@ -10,13 +10,13 @@ namespace DebuggerLibrary @@ -10,13 +10,13 @@ namespace DebuggerLibrary
{
internal class VariableFactory
{
public static Variable CreateVariable(ICorDebugValue corValue, string name)
public static Variable CreateVariable(NDebugger debugger, ICorDebugValue corValue, string name)
{
CorElementType type = Variable.GetCorType(corValue);
if (Variable.DereferenceUnbox(corValue) == null)
{
return new NullRefVariable(corValue, name);
return new NullRefVariable(debugger, corValue, name);
}
switch(type)
@ -36,19 +36,19 @@ namespace DebuggerLibrary @@ -36,19 +36,19 @@ namespace DebuggerLibrary
case CorElementType.I:
case CorElementType.U:
case CorElementType.STRING:
return new BuiltInVariable(corValue, name);
return new BuiltInVariable(debugger, corValue, name);
case CorElementType.ARRAY:
case CorElementType.SZARRAY: // Short-cut for single dimension zero lower bound array
return new ArrayVariable(corValue, name);
return new ArrayVariable(debugger, corValue, name);
case CorElementType.VALUETYPE:
case CorElementType.CLASS:
case CorElementType.OBJECT: // Short-cut for Class "System.Object"
return new ObjectVariable(corValue, name);
return new ObjectVariable(debugger, corValue, name);
default: // Unknown type
return new UnknownVariable(corValue, name);
return new UnknownVariable(debugger, corValue, name);
}
}
}

Loading…
Cancel
Save