diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj index e32feb9d0b..8c57d0f469 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj @@ -60,14 +60,14 @@ - - + + - - - + + + - + diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-AppDomains.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/AppDomainCollection.cs similarity index 100% rename from src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-AppDomains.cs rename to src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/AppDomainCollection.cs diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/NDebugger-Breakpoints.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/BreakpointCollection.cs similarity index 85% rename from src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/NDebugger-Breakpoints.cs rename to src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/BreakpointCollection.cs index a248f61420..0608831153 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/NDebugger-Breakpoints.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/BreakpointCollection.cs @@ -11,15 +11,6 @@ using Debugger.Wrappers.CorDebug; namespace Debugger { - public partial class NDebugger - { - BreakpointCollection breakpoints; - - public BreakpointCollection Breakpoints { - get { return breakpoints; } - } - } - public class BreakpointCollection: CollectionWithEvents { public event EventHandler> Hit; @@ -31,19 +22,17 @@ namespace Debugger } } - public BreakpointCollection(NDebugger debugger):base(debugger) - { - - } + public BreakpointCollection(NDebugger debugger):base(debugger) { } - internal Breakpoint Get(ICorDebugBreakpoint corBreakpoint) - { - foreach (Breakpoint breakpoint in this) { - if (breakpoint.IsOwnerOf(corBreakpoint)) { - return breakpoint; + internal Breakpoint this[ICorDebugBreakpoint corBreakpoint] { + get { + foreach (Breakpoint breakpoint in this) { + if (breakpoint.IsOwnerOf(corBreakpoint)) { + return breakpoint; + } } + return null; } - return null; } public new void Add(Breakpoint breakpoint) diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-Evals.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/EvalCollection.cs similarity index 53% rename from src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-Evals.cs rename to src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/EvalCollection.cs index 46b2195abd..1bc36b8b6e 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-Evals.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/EvalCollection.cs @@ -11,31 +11,19 @@ using Debugger.Wrappers.CorDebug; namespace Debugger { - public partial class Process - { - EvalCollection evals; - - public EvalCollection ActiveEvals { - get { return evals; } - } - - internal bool Evaluating { - get { return evals.Count > 0; } - } - } - public class EvalCollection: CollectionWithEvents { public EvalCollection(NDebugger debugger): base(debugger) {} - internal Eval Get(ICorDebugEval corEval) - { - foreach(Eval eval in this) { - if (eval.IsCorEval(corEval)) { - return eval; + internal Eval this[ICorDebugEval corEval] { + get { + foreach(Eval eval in this) { + if (eval.IsCorEval(corEval)) { + return eval; + } } + throw new DebuggerException("Eval not found for given ICorDebugEval"); } - throw new DebuggerException("Eval not found for given ICorDebugEval"); } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-Modules.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/ModuleCollection.cs similarity index 76% rename from src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-Modules.cs rename to src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/ModuleCollection.cs index 8dcf9367c0..8845a748cc 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-Modules.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/ModuleCollection.cs @@ -12,15 +12,6 @@ using Debugger.Wrappers.CorDebug; namespace Debugger { - public partial class Process - { - ModuleCollection modules; - - public ModuleCollection Modules { - get { return modules; } - } - } - public class ModuleCollection: CollectionWithEvents { public ModuleCollection(NDebugger debugger):base (debugger) {} @@ -38,15 +29,15 @@ namespace Debugger } } - internal Module Get(ICorDebugModule corModule) - { - foreach(Module module in this) { - if (module.CorModule == corModule) { - return module; + internal Module this[ICorDebugModule corModule] { + get { + foreach(Module module in this) { + if (module.CorModule == corModule) { + return module; + } } + throw new DebuggerException("Module is not in collection"); } - - throw new DebuggerException("Module is not in collection"); } protected override void OnAdded(Module module) diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/NDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/NDebugger.cs index e754af6bd9..f016ee6987 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/NDebugger.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/NDebugger.cs @@ -22,6 +22,9 @@ namespace Debugger ManagedCallbackSwitch managedCallbackSwitch; ManagedCallbackProxy managedCallbackProxy; + BreakpointCollection breakpoints; + ProcessCollection processes; + MTA2STA mta2sta = new MTA2STA(); string debuggeeVersion; @@ -51,6 +54,14 @@ namespace Debugger set { options = value; } } + public BreakpointCollection Breakpoints { + get { return breakpoints; } + } + + public ProcessCollection Processes { + get { return processes; } + } + public NDebugger() { processes = new ProcessCollection(this); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process.cs index 3c1ed3b008..7d3028f80f 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process.cs @@ -18,6 +18,10 @@ namespace Debugger ICorDebugProcess corProcess; ManagedCallback callbackInterface; + EvalCollection activeEvals; + ModuleCollection modules; + ThreadCollection threads; + #region IExpirable bool hasExited = false; @@ -65,6 +69,27 @@ namespace Debugger } } + public EvalCollection ActiveEvals { + get { return activeEvals; } + } + + internal bool Evaluating { + get { return activeEvals.Count > 0; } + } + + public ModuleCollection Modules { + get { return modules; } + } + + public ThreadCollection Threads { + get { return threads; } + } + + public Thread SelectedThread { + get { return this.Threads.Selected; } + set { this.Threads.Selected = value; } + } + internal Process(NDebugger debugger, ICorDebugProcess corProcess) { this.debugger = debugger; @@ -72,7 +97,7 @@ namespace Debugger this.callbackInterface = new ManagedCallback(this); - evals = new EvalCollection(debugger); + activeEvals = new EvalCollection(debugger); modules = new ModuleCollection(debugger); threads = new ThreadCollection(debugger); } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/NDebugger-Processes.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/ProcessCollection.cs similarity index 63% rename from src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/NDebugger-Processes.cs rename to src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/ProcessCollection.cs index db4d7a1803..6b576a4111 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/NDebugger-Processes.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/ProcessCollection.cs @@ -12,30 +12,19 @@ using Debugger.Wrappers.CorDebug; namespace Debugger { - public partial class NDebugger - { - ProcessCollection processes; - - public ProcessCollection Processes { - get { return processes; } - } - } - public class ProcessCollection: CollectionWithEvents { - public ProcessCollection(NDebugger debugger): base(debugger) - { - - } + public ProcessCollection(NDebugger debugger): base(debugger) {} - internal Process Get(ICorDebugProcess corProcess) - { - foreach (Process process in this) { - if (process.CorProcess == corProcess) { - return process; + internal Process this[ICorDebugProcess corProcess] { + get { + foreach (Process process in this) { + if (process.CorProcess == corProcess) { + return process; + } } + return null; } - return null; } protected override void OnRemoved(Process item) diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-Threads.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/ThreadCollection.cs similarity index 61% rename from src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-Threads.cs rename to src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/ThreadCollection.cs index 07658b1ea3..e3373442fc 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/Process-Threads.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Control/ThreadCollection.cs @@ -12,20 +12,6 @@ using Debugger.Wrappers.CorDebug; namespace Debugger { - public partial class Process - { - ThreadCollection threads; - - public ThreadCollection Threads { - get { return threads; } - } - - public Thread SelectedThread { - get { return this.Threads.Selected; } - set { this.Threads.Selected = value; } - } - } - public class ThreadCollection: CollectionWithEvents { public ThreadCollection(NDebugger debugger): base(debugger) {} @@ -45,14 +31,15 @@ namespace Debugger return false; } - internal Thread Get(ICorDebugThread corThread) - { - foreach(Thread thread in this) { - if (thread.CorThread == corThread) { - return thread; + internal Thread this[ICorDebugThread corThread] { + get { + foreach(Thread thread in this) { + if (thread.CorThread == corThread) { + return thread; + } } + throw new DebuggerException("Thread is not in collection"); } - throw new DebuggerException("Thread is not in collection"); } } } diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs index acf4240695..976fc76098 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallback.cs @@ -78,7 +78,7 @@ namespace Debugger void EnterCallback(PausedReason pausedReason, string name, ICorDebugThread pThread) { EnterCallback(pausedReason, name, pThread.Process); - process.SelectedThread = process.Threads.Get(pThread); + process.SelectedThread = process.Threads[pThread]; } void ExitCallback() @@ -123,7 +123,7 @@ namespace Debugger { EnterCallback(PausedReason.StepComplete, "StepComplete (" + reason.ToString() + ")", pThread); - Thread thread = process.Threads.Get(pThread); + Thread thread = process.Threads[pThread]; Stepper stepper = thread.GetStepper(pStepper); StackFrame currentStackFrame = process.SelectedThread.MostRecentStackFrame; @@ -164,7 +164,7 @@ namespace Debugger { EnterCallback(PausedReason.Breakpoint, "Breakpoint", pThread); - Breakpoint breakpoint = process.Debugger.Breakpoints.Get(corBreakpoint); + Breakpoint breakpoint = process.Debugger.Breakpoints[corBreakpoint]; // The event will be risen outside the callback process.BreakpointHitEventQueue.Enqueue(breakpoint); @@ -256,7 +256,7 @@ namespace Debugger void HandleEvalComplete(ICorDebugAppDomain pAppDomain, ICorDebugThread pThread, ICorDebugEval corEval, bool exception) { // Let the eval know that the CorEval has finished - Eval eval = process.ActiveEvals.Get(corEval); + Eval eval = process.ActiveEvals[corEval]; eval.NotifyEvaluationComplete(!exception); process.ActiveEvals.Remove(eval); @@ -354,7 +354,7 @@ namespace Debugger EnterCallback(PausedReason.Other, "NameChange: pThread", pThread); - Thread thread = process.Threads.Get(pThread); + Thread thread = process.Threads[pThread]; thread.NotifyNameChanged(); ExitCallback(); @@ -395,7 +395,7 @@ namespace Debugger { EnterCallback(PausedReason.Other, "UnloadModule", pAppDomain); - process.Modules.Remove(process.Modules.Get(pModule)); + process.Modules.Remove(process.Modules[pModule]); ExitCallback(); } @@ -413,7 +413,7 @@ namespace Debugger if (process.Threads.Contains(pThread)) { EnterCallback(PausedReason.Other, "ExitThread " + pThread.ID, pThread); - process.Threads.Get(pThread).NotifyExited(); + process.Threads[pThread].NotifyExited(); } else { EnterCallback(PausedReason.Other, "ExitThread " + pThread.ID, process.CorProcess); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallbackSwitch.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallbackSwitch.cs index af236320e6..b91524d15d 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallbackSwitch.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Internal/ManagedCallbackSwitch.cs @@ -73,7 +73,7 @@ namespace Debugger public ManagedCallback GetProcessCallbackInterface(string name, ICorDebugProcess pProcess) { - Process process = debugger.Processes.Get(pProcess); + Process process = debugger.Processes[pProcess]; // Make *really* sure the process is not dead if (process == null) { debugger.TraceMessage("Ignoring callback \"" + name + "\": Process not found"); diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs index db628f45ab..17b65032e2 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Metadata/DebugType.cs @@ -337,7 +337,7 @@ namespace Debugger.MetaData this.corElementType = (CorElementType)corType.Type; if (this.IsClass || this.IsValueType) { - this.module = process.Modules.Get(corType.Class.Module); + this.module = process.Modules[corType.Class.Module]; this.classProps = module.MetaData.GetTypeDefProps(corType.Class.Token); } @@ -476,7 +476,7 @@ namespace Debugger.MetaData static public DebugType Create(Process process, ICorDebugClass corClass, params ICorDebugType[] typeArguments) { - MetaDataImport metaData = process.Modules.Get(corClass.Module).MetaData; + MetaDataImport metaData = process.Modules[corClass.Module].MetaData; bool isValueType = false; uint superClassToken = metaData.GetTypeDefProps(corClass.Token).SuperClassToken; diff --git a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/MainThreadExit.cs b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/MainThreadExit.cs index 631010b5e9..abe8bacb78 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/MainThreadExit.cs +++ b/src/AddIns/Misc/Debugger/Debugger.Tests/Project/Src/TestPrograms/MainThreadExit.cs @@ -62,7 +62,8 @@ namespace Debugger.Tests { MainThreadExit.exe (Has symbols) Break MainThreadExit.cs:24,4-24,40 + Count="2" + Selected="Thread Name = Suspended = False"> ForcedBreak MainThreadExit.cs:29,4-29,26 + Count="2" + Selected="Thread Name = Worker thread Suspended = False">