Browse Source

Worked on replacing strong typed collections with generics ones

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@62 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 21 years ago
parent
commit
063d07954f
  1. 12
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/BreakPointsPad.cs
  2. 6
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Pads/LoadedModulesPad.cs
  3. 8
      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. 12
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  6. 3
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj.user
  7. 6
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/Breakpoint.cs
  8. 156
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/BreakpointCollection.cs
  9. 125
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/NDebugger-Breakpoints.cs
  10. 26
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
  11. 77
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  12. 101
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/ModuleCollection.cs
  13. 96
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/NDebugger-Modules.cs
  14. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Function.cs
  15. 39
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/FunctionCollection.cs
  16. 89
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Threads.cs
  17. 9
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Thread.cs
  18. 103
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/ThreadCollection.cs
  19. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Variables/ObjectVariable.cs

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

@ -56,10 +56,10 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -56,10 +56,10 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
path.Width = 400;
NDebugger.DebuggingResumed += new DebuggerEventHandler(debuggerService_OnDebuggingResumed);
NDebugger.Breakpoints.BreakpointAdded += new DebuggerLibrary.BreakpointEventHandler(AddBreakpoint);
NDebugger.Breakpoints.BreakpointStateChanged += new DebuggerLibrary.BreakpointEventHandler(RefreshBreakpoint);
NDebugger.Breakpoints.BreakpointRemoved += new DebuggerLibrary.BreakpointEventHandler(RemoveBreakpoint);
NDebugger.Breakpoints.BreakpointHit += new DebuggerLibrary.BreakpointEventHandler(Breakpoints_OnBreakpointHit);
NDebugger.Instance.BreakpointAdded += new DebuggerLibrary.BreakpointEventHandler(AddBreakpoint);
NDebugger.Instance.BreakpointStateChanged += new DebuggerLibrary.BreakpointEventHandler(RefreshBreakpoint);
NDebugger.Instance.BreakpointRemoved += new DebuggerLibrary.BreakpointEventHandler(RemoveBreakpoint);
NDebugger.Instance.BreakpointHit += new DebuggerLibrary.BreakpointEventHandler(Breakpoints_OnBreakpointHit);
RedrawContent();
}
@ -88,7 +88,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -88,7 +88,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
breakpointsList.ItemCheck -= new ItemCheckEventHandler(BreakpointsListItemCheck);
breakpointsList.BeginUpdate();
breakpointsList.Items.Clear();
foreach(DebuggerLibrary.Breakpoint b in NDebugger.Breakpoints) {
foreach(DebuggerLibrary.Breakpoint b in NDebugger.Instance.Breakpoints) {
AddBreakpoint(this, new BreakpointEventArgs(b));
}
breakpointsList.EndUpdate();
@ -138,7 +138,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -138,7 +138,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
void debuggerService_OnDebuggingResumed(object sender, DebuggerEventArgs e)
{
breakpointsList.BeginUpdate();
foreach(DebuggerLibrary.Breakpoint b in NDebugger.Breakpoints)
foreach(DebuggerLibrary.Breakpoint b in NDebugger.Instance.Breakpoints)
RefreshBreakpoint(this, new BreakpointEventArgs(b));
breakpointsList.EndUpdate();
}

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

@ -64,8 +64,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -64,8 +64,8 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
timestamp.Width = 0;//80;
information.Width = 130;
NDebugger.Modules.ModuleAdded += new DebuggerLibrary.ModuleEventHandler(AddModule);
NDebugger.Modules.ModuleRemoved += new DebuggerLibrary.ModuleEventHandler(RemoveModule);
NDebugger.Instance.ModuleLoaded += new DebuggerLibrary.ModuleEventHandler(AddModule);
NDebugger.Instance.ModuleUnloaded += new DebuggerLibrary.ModuleEventHandler(RemoveModule);
RedrawContent();
}
@ -83,7 +83,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -83,7 +83,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
information.Text = StringParser.Parse("${res:MainWindow.Windows.Debug.InformationColumn}");
loadedModulesList.Items.Clear();
foreach(Module m in NDebugger.Modules) {
foreach(Module m in NDebugger.Instance.Modules) {
AddModule(this, new ModuleEventArgs(m));
}
}

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

@ -65,9 +65,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -65,9 +65,9 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
breaked.Width = 80;
NDebugger.Threads.ThreadAdded += new ThreadEventHandler(AddThread);
NDebugger.Threads.ThreadStateChanged += new ThreadEventHandler(RefreshThread);
NDebugger.Threads.ThreadRemoved += new ThreadEventHandler(RemoveThread);
NDebugger.Instance.ThreadStarted += new ThreadEventHandler(AddThread);
NDebugger.Instance.ThreadStateChanged += new ThreadEventHandler(RefreshThread);
NDebugger.Instance.ThreadExited += new ThreadEventHandler(RemoveThread);
NDebugger.IsProcessRunningChanged += new DebuggerEventHandler(DebuggerStateChanged);
RedrawContent();
@ -135,7 +135,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads @@ -135,7 +135,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
private void RefreshAllItems()
{
foreach (Thread t in NDebugger.Threads) {
foreach (Thread t in NDebugger.Instance.Threads) {
RefreshThread(this, new ThreadEventArgs(t));
}
}

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

@ -379,7 +379,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -379,7 +379,7 @@ namespace ICSharpCode.SharpDevelop.Services
Point logicPos = iconBar.TextArea.TextView.GetLogicalPosition(0, mousepos.Y - viewRect.Top);
if (logicPos.Y >= 0 && logicPos.Y < iconBar.TextArea.Document.TotalNumberOfLines) {
NDebugger.ToggleBreakpointAt(iconBar.TextArea.MotherTextEditorControl.FileName , logicPos.Y + 1, 0);
NDebugger.Instance.ToggleBreakpointAt(iconBar.TextArea.MotherTextEditorControl.FileName , logicPos.Y + 1, 0);
RefreshBreakpointMarkersInEditor(iconBar.TextArea.MotherTextEditorControl);
iconBar.TextArea.Refresh(iconBar);
}
@ -399,7 +399,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -399,7 +399,7 @@ namespace ICSharpCode.SharpDevelop.Services
}
}
// Add breakpoint markers
foreach (DebuggerLibrary.Breakpoint b in NDebugger.Breakpoints) {
foreach (DebuggerLibrary.Breakpoint b in NDebugger.Instance.Breakpoints) {
if (b.SourcecodeSegment.SourceFilename.ToLower() == textEditor.FileName.ToLower()) {
LineSegment lineSeg = document.GetLineSegment((int)b.SourcecodeSegment.StartLine - 1);
document.MarkerStrategy.TextMarker.Add(new BreakpointMarker(lineSeg.Offset, lineSeg.Length , TextMarkerType.SolidBlock, Color.Red));
@ -486,7 +486,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -486,7 +486,7 @@ namespace ICSharpCode.SharpDevelop.Services
/// </summary>
void PaintIconBar(AbstractMargin iconBar, Graphics g, Rectangle rect)
{
foreach (DebuggerLibrary.Breakpoint breakpoint in NDebugger.Breakpoints) {
foreach (DebuggerLibrary.Breakpoint breakpoint in NDebugger.Instance.Breakpoints) {
if (Path.GetFullPath(breakpoint.SourcecodeSegment.SourceFilename) == Path.GetFullPath(iconBar.TextArea.MotherTextEditorControl.FileName)) {
int lineNumber = iconBar.TextArea.Document.GetVisibleLine((int)breakpoint.SourcecodeSegment.StartLine - 1);
int yPos = (int)(lineNumber * iconBar.TextArea.TextView.FontHeight) - iconBar.TextArea.VirtualTop.Y;

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

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@ -9,6 +9,9 @@ @@ -9,6 +9,9 @@
<RootNamespace>Debugger.Core</RootNamespace>
<AssemblyName>Debugger.Core</AssemblyName>
<WarningLevel>4</WarningLevel>
<AssemblyOriginatorKeyFile />
<AssemblyKeyProviderName />
<AssemblyOriginatorKeyMode>File</AssemblyOriginatorKeyMode>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
@ -38,8 +41,8 @@ @@ -38,8 +41,8 @@
<ItemGroup>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\Breakpoints\Breakpoint.cs" />
<Compile Include="Src\Breakpoints\BreakpointCollection.cs" />
<Compile Include="Src\Breakpoints\BreakpointEventHandler.cs" />
<Compile Include="Src\Breakpoints\NDebugger-Breakpoints.cs" />
<Compile Include="Src\Debugger\DebuggerEvents\DebuggerEventHandler.cs" />
<Compile Include="Src\Debugger\DebuggerEvents\DebuggingIsResumingEventHandler.cs" />
<Compile Include="Src\Debugger\DebuggerEvents\DebuggingPausedEventHandler.cs" />
@ -57,14 +60,13 @@ @@ -57,14 +60,13 @@
<Compile Include="Src\Interop enums\CorMethodAttr.cs" />
<Compile Include="Src\Interop enums\CorTokenType.cs" />
<Compile Include="Src\Modules\Module.cs" />
<Compile Include="Src\Modules\ModuleCollection.cs" />
<Compile Include="Src\Modules\ModuleEventHandler.cs" />
<Compile Include="Src\Modules\NDebugger-Modules.cs" />
<Compile Include="Src\Threads\Exception.cs" />
<Compile Include="Src\Threads\Function.cs" />
<Compile Include="Src\Threads\FunctionCollection.cs" />
<Compile Include="Src\Threads\NDebugger-Threads.cs" />
<Compile Include="Src\Threads\SourcecodeSegment.cs" />
<Compile Include="Src\Threads\Thread.cs" />
<Compile Include="Src\Threads\ThreadCollection.cs" />
<Compile Include="Src\Threads\ThreadEventHandler.cs" />
<Compile Include="Src\Variables\ArrayVariable.cs" />
<Compile Include="Src\Variables\BuiltInVariable.cs" />

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

@ -1,7 +1,8 @@ @@ -1,7 +1,8 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<LastOpenVersion>8.0.41115</LastOpenVersion>
<ProjectView>ShowAllFiles</ProjectView>
<ProjectTrust>0</ProjectTrust>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " />
</Project>

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

@ -138,8 +138,8 @@ namespace DebuggerLibrary @@ -138,8 +138,8 @@ namespace DebuggerLibrary
{
try
{
module = NDebugger.Modules[seg.ModuleFilename];
symReader = NDebugger.Modules[seg.ModuleFilename].SymReader;
module = NDebugger.Instance.GetModule(seg.ModuleFilename);
symReader = NDebugger.Instance.GetModule(seg.ModuleFilename).SymReader;
symDoc = symReader.GetDocument(seg.SourceFilename,Guid.Empty,Guid.Empty,Guid.Empty);
}
catch {}
@ -147,7 +147,7 @@ namespace DebuggerLibrary @@ -147,7 +147,7 @@ namespace DebuggerLibrary
// search all modules
if (symDoc == null) {
foreach (Module m in NDebugger.Modules) {
foreach (Module m in NDebugger.Instance.Modules) {
module = m;
symReader = m.SymReader;
if (symReader == null) {

156
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Breakpoints/BreakpointCollection.cs

@ -1,156 +0,0 @@ @@ -1,156 +0,0 @@
// <file>
// <owner name="David Srbecký" email="dsrbecky@post.cz"/>
// </file>
using System;
using System.Runtime.InteropServices;
using System.Collections;
using DebuggerInterop.Core;
using DebuggerInterop.MetaData;
namespace DebuggerLibrary
{
public class BreakpointCollection: CollectionBase
{
internal BreakpointCollection()
{
NDebugger.Modules.ModuleAdded += new ModuleEventHandler(SetBreakpointsInModule);
}
public event BreakpointEventHandler BreakpointAdded;
private void OnBreakpointAdded(Breakpoint breakpoint)
{
breakpoint.BreakpointStateChanged += new BreakpointEventHandler(OnBreakpointStateChanged);
breakpoint.BreakpointHit += new BreakpointEventHandler(OnBreakpointHit);
if (BreakpointAdded != null)
BreakpointAdded(this, new BreakpointEventArgs(breakpoint));
}
public event BreakpointEventHandler BreakpointRemoved;
private void OnBreakpointRemoved(Breakpoint breakpoint)
{
breakpoint.BreakpointStateChanged -= new BreakpointEventHandler(OnBreakpointStateChanged);
breakpoint.BreakpointHit -= new BreakpointEventHandler(OnBreakpointHit);
if (BreakpointRemoved != null)
BreakpointRemoved(this, new BreakpointEventArgs(breakpoint));
}
public event BreakpointEventHandler BreakpointStateChanged;
private void OnBreakpointStateChanged(object sender, BreakpointEventArgs e)
{
if (BreakpointStateChanged != null)
BreakpointStateChanged(this, new BreakpointEventArgs(e.Breakpoint));
}
public event BreakpointEventHandler BreakpointHit;
private void OnBreakpointHit(object sender, BreakpointEventArgs e)
{
if (BreakpointHit != null)
BreakpointHit(this, new BreakpointEventArgs(e.Breakpoint));
}
public Breakpoint this[int index]
{
get
{
return( (Breakpoint) List[index] );
}
set
{
Breakpoint oldValue = (Breakpoint)List[index];
List[index] = value;
OnBreakpointRemoved( oldValue );
OnBreakpointAdded( value );
}
}
internal Breakpoint this[ICorDebugBreakpoint corBreakpoint]
{
get
{
foreach(Breakpoint breakpoint in InnerList)
if (breakpoint == corBreakpoint)
return breakpoint;
throw new UnableToGetPropertyException(this, "this[ICorDebugBreakpoint]", "Breakpoint is not in collection");
}
}
public int Add(Breakpoint breakpoint)
{
System.Diagnostics.Trace.Assert(breakpoint != null);
if (breakpoint != null)
{
int retVal = List.Add(breakpoint);
breakpoint.SetBreakpoint();
OnBreakpointAdded(breakpoint);
return retVal;
} else {
return -1;
}
}
public int Add(SourcecodeSegment segment)
{
return Add(new Breakpoint(segment));
}
public int Add(int line)
{
return Add(new Breakpoint(line));
}
public int Add(string sourceFilename, int line)
{
return Add(new Breakpoint(sourceFilename, line));
}
public int Add(string sourceFilename, int line, int column)
{
return Add(new Breakpoint(sourceFilename, line, column));
}
public int IndexOf( Breakpoint breakpoint )
{
return( List.IndexOf( breakpoint ) );
}
public void Insert( int index, Breakpoint breakpoint )
{
System.Diagnostics.Trace.Assert(breakpoint != null);
if (breakpoint != null)
{
List.Insert( index, breakpoint );
OnBreakpointAdded(breakpoint);
}
}
public void Remove( Breakpoint breakpoint )
{
breakpoint.Enabled = false;
List.Remove( breakpoint );
OnBreakpointRemoved( breakpoint);
}
public bool Contains( Breakpoint breakpoint )
{
return( List.Contains( breakpoint ) );
}
private void SetBreakpointsInModule(object sender, ModuleEventArgs e)
{
foreach (Breakpoint b in InnerList) {
b.SetBreakpoint();
}
}
}
}

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

@ -0,0 +1,125 @@ @@ -0,0 +1,125 @@
// <file>
// <owner name="David Srbecký" email="dsrbecky@post.cz"/>
// </file>
using System;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using DebuggerInterop.Core;
using DebuggerInterop.MetaData;
namespace DebuggerLibrary
{
public partial class NDebugger
{
List<Breakpoint> breakpointCollection = new List<Breakpoint>();
public event BreakpointEventHandler BreakpointAdded;
public event BreakpointEventHandler BreakpointRemoved;
public event BreakpointEventHandler BreakpointStateChanged;
public event BreakpointEventHandler BreakpointHit;
protected void OnBreakpointAdded(Breakpoint breakpoint)
{
if (BreakpointAdded != null) {
BreakpointAdded(this, new BreakpointEventArgs(breakpoint));
}
}
protected void OnBreakpointRemoved(Breakpoint breakpoint)
{
if (BreakpointRemoved != null) {
BreakpointRemoved(this, new BreakpointEventArgs(breakpoint));
}
}
protected void OnBreakpointStateChanged(object sender, BreakpointEventArgs e)
{
if (BreakpointStateChanged != null) {
BreakpointStateChanged(this, new BreakpointEventArgs(e.Breakpoint));
}
}
protected void OnBreakpointHit(object sender, BreakpointEventArgs e)
{
if (BreakpointHit != null) {
BreakpointHit(this, new BreakpointEventArgs(e.Breakpoint));
}
}
public IList<Breakpoint> Breakpoints {
get {
return breakpointCollection.AsReadOnly();
}
}
internal Breakpoint GetBreakpoint(ICorDebugBreakpoint corBreakpoint)
{
foreach(Breakpoint breakpoint in breakpointCollection) {
if (breakpoint == corBreakpoint) {
return breakpoint;
}
}
throw new UnableToGetPropertyException(this, "GetBreakpoint(ICorDebugBreakpoint corBreakpoint)", "Breakpoint is not in collection");
}
public Breakpoint AddBreakpoint(Breakpoint breakpoint)
{
breakpointCollection.Add(breakpoint);
breakpoint.SetBreakpoint();
breakpoint.BreakpointStateChanged += new BreakpointEventHandler(OnBreakpointStateChanged);
breakpoint.BreakpointHit += new BreakpointEventHandler(OnBreakpointHit);
OnBreakpointAdded(breakpoint);
return breakpoint;
}
public Breakpoint AddBreakpoint(SourcecodeSegment segment)
{
return AddBreakpoint(new Breakpoint(segment));
}
public Breakpoint AddBreakpoint(int line)
{
return AddBreakpoint(new Breakpoint(line));
}
public Breakpoint AddBreakpoint(string sourceFilename, int line)
{
return AddBreakpoint(new Breakpoint(sourceFilename, line));
}
public Breakpoint AddBreakpoint(string sourceFilename, int line, int column)
{
return AddBreakpoint(new Breakpoint(sourceFilename, line, column));
}
public void RemoveBreakpoint(Breakpoint breakpoint)
{
breakpoint.BreakpointStateChanged -= new BreakpointEventHandler(OnBreakpointStateChanged);
breakpoint.BreakpointHit -= new BreakpointEventHandler(OnBreakpointHit);
breakpoint.Enabled = false;
breakpointCollection.Remove( breakpoint );
OnBreakpointRemoved( breakpoint);
}
internal void ResetBreakpoints()
{
foreach (Breakpoint b in breakpointCollection) {
b.ResetBreakpoint();
}
}
internal void SetBreakpointsInModule(object sender, ModuleEventArgs e)
{
foreach (Breakpoint b in breakpointCollection) {
b.SetBreakpoint();
}
}
}
}

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

@ -57,7 +57,7 @@ namespace DebuggerLibrary @@ -57,7 +57,7 @@ namespace DebuggerLibrary
{
EnterCallback("StepComplete");
NDebugger.CurrentThread = NDebugger.Threads[pThread];
NDebugger.CurrentThread = NDebugger.Instance.GetThread(pThread);
if (NDebugger.CurrentThread.CurrentFunction.Module.SymbolsLoaded == false) {
NDebugger.TraceMessage(" - stepping out of code without symbols");
@ -72,11 +72,11 @@ namespace DebuggerLibrary @@ -72,11 +72,11 @@ namespace DebuggerLibrary
{
EnterCallback("Breakpoint");
NDebugger.CurrentThread = NDebugger.Threads[pThread];
NDebugger.CurrentThread = NDebugger.Instance.GetThread(pThread);
ExitCallback_Paused(PausedReason.Breakpoint);
foreach (Breakpoint b in NDebugger.Breakpoints) {
foreach (Breakpoint b in NDebugger.Instance.Breakpoints) {
if (b.Equals(pBreakpoint)) {
b.OnBreakpointHit();
}
@ -94,7 +94,7 @@ namespace DebuggerLibrary @@ -94,7 +94,7 @@ namespace DebuggerLibrary
{
EnterCallback("Break");
NDebugger.CurrentThread = NDebugger.Threads[pThread];
NDebugger.CurrentThread = NDebugger.Instance.GetThread(pThread);
ExitCallback_Paused(PausedReason.Break);
}
@ -115,7 +115,7 @@ namespace DebuggerLibrary @@ -115,7 +115,7 @@ namespace DebuggerLibrary
// return;
//}
NDebugger.CurrentThread = NDebugger.Threads[pThread];
NDebugger.CurrentThread = NDebugger.Instance.GetThread(pThread);
NDebugger.CurrentThread.CurrentExceptionIsHandled = (unhandled == 0);
ExitCallback_Paused(PausedReason.Exception);
@ -213,7 +213,7 @@ namespace DebuggerLibrary @@ -213,7 +213,7 @@ namespace DebuggerLibrary
{
EnterCallback("LoadModule");
NDebugger.Modules.Add(pModule);
NDebugger.Instance.AddModule(pModule);
ExitCallback_Continue(pAppDomain);
}
@ -229,7 +229,7 @@ namespace DebuggerLibrary @@ -229,7 +229,7 @@ namespace DebuggerLibrary
if (pThread != null)
{
EnterCallback("NameChange: pThread");
NDebugger.Threads[pThread].OnThreadStateChanged();
NDebugger.Instance.GetThread(pThread).OnThreadStateChanged();
ExitCallback_Continue();
return;
}
@ -239,10 +239,10 @@ namespace DebuggerLibrary @@ -239,10 +239,10 @@ namespace DebuggerLibrary
{
EnterCallback("CreateThread");
NDebugger.Threads.Add(pThread);
NDebugger.Instance.AddThread(pThread);
if (NDebugger.MainThread == null) {
NDebugger.MainThread = NDebugger.Threads[pThread];
NDebugger.MainThread = NDebugger.Instance.GetThread(pThread);
}
ExitCallback_Continue(pAppDomain);
@ -270,7 +270,7 @@ namespace DebuggerLibrary @@ -270,7 +270,7 @@ namespace DebuggerLibrary
{
EnterCallback("UnloadModule");
NDebugger.Modules.Remove(pModule);
NDebugger.Instance.RemoveModule(pModule);
ExitCallback_Continue(pAppDomain);
}
@ -286,7 +286,7 @@ namespace DebuggerLibrary @@ -286,7 +286,7 @@ namespace DebuggerLibrary
{
EnterCallback("ExitThread");
Thread thread = NDebugger.Threads[pThread];
Thread thread = NDebugger.Instance.GetThread(pThread);
if (NDebugger.CurrentThread == thread)
NDebugger.CurrentThread = null;
@ -294,7 +294,7 @@ namespace DebuggerLibrary @@ -294,7 +294,7 @@ namespace DebuggerLibrary
if (NDebugger.MainThread == thread)
NDebugger.MainThread = null;
NDebugger.Threads.Remove(thread);
NDebugger.Instance.RemoveThread(thread);
try { // TODO
ExitCallback_Continue(pAppDomain);
@ -312,7 +312,7 @@ namespace DebuggerLibrary @@ -312,7 +312,7 @@ namespace DebuggerLibrary
{
EnterCallback("ExitProcess");
NDebugger.ResetEnvironment();
NDebugger.Instance.ResetEnvironment();
pProcess.Continue(0); //TODO
}

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

@ -13,8 +13,20 @@ using DebuggerInterop.MetaData; @@ -13,8 +13,20 @@ using DebuggerInterop.MetaData;
namespace DebuggerLibrary
{
public class NDebugger
public partial class NDebugger
{
static NDebugger instance = new NDebugger();
public static NDebugger Instance {
get {
return instance;
}
set {
instance = value;
}
}
// Some variables that are used to get strings
// They are used all over the library and
// they are here so I don't have to decare them every time I need them
@ -37,33 +49,11 @@ namespace DebuggerLibrary @@ -37,33 +49,11 @@ namespace DebuggerLibrary
static ICorDebugProcess mainProcess;
static Thread mainThread;
static Thread currentThread;
static BreakpointCollection breakpoints;
static ThreadCollection threads;
static ModuleCollection modules;
public static bool CatchHandledExceptions = false;
#region Public propeties
static public BreakpointCollection Breakpoints {
get{
return breakpoints;
}
}
static public ThreadCollection Threads {
get{
return threads;
}
}
static public ModuleCollection Modules {
get{
return modules;
}
}
static public SourcecodeSegment NextStatement {
get{
try {
@ -153,10 +143,12 @@ namespace DebuggerLibrary @@ -153,10 +143,12 @@ namespace DebuggerLibrary
#region Basic functions
static NDebugger()
private NDebugger()
{
InitDebugger();
ResetEnvironment();
this.ModuleLoaded += new ModuleEventHandler(SetBreakpointsInModule);
}
~NDebugger() //TODO
@ -164,14 +156,6 @@ namespace DebuggerLibrary @@ -164,14 +156,6 @@ namespace DebuggerLibrary
corDebug.Terminate();
Marshal.FreeHGlobal(pString);
}
/// <summary>
/// It is not possible to implicitly create instance
/// </summary>
private NDebugger()
{
}
static internal void InitDebugger()
{
@ -190,27 +174,13 @@ namespace DebuggerLibrary @@ -190,27 +174,13 @@ namespace DebuggerLibrary
corDebug.SetManagedHandler(managedCallbackProxy);
}
static internal void ResetEnvironment()
internal void ResetEnvironment()
{
if (modules == null) {
modules = new ModuleCollection();
} else {
modules.Clear();
}
ClearModules();
if (breakpoints == null) {
breakpoints = new BreakpointCollection();
} else {
foreach (Breakpoint b in breakpoints) {
b.ResetBreakpoint();
}
}
ResetBreakpoints();
if (threads == null) {
threads = new ThreadCollection();
} else {
threads.Clear();
}
ClearThreads();
MainProcess = null;
mainThread = null;
@ -476,7 +446,7 @@ namespace DebuggerLibrary @@ -476,7 +446,7 @@ namespace DebuggerLibrary
#endregion
static public void ToggleBreakpointAt(string fileName, int line, int column)
public void ToggleBreakpointAt(string fileName, int line, int column)
{
// Check if there is breakpoint on that line
foreach (Breakpoint breakpoint in Breakpoints) {
@ -488,15 +458,14 @@ namespace DebuggerLibrary @@ -488,15 +458,14 @@ namespace DebuggerLibrary
}
// Add the breakpoint
int index = Breakpoints.Add(fileName, line, column);
Breakpoint addedBreakpoint = breakpoints[index];
Breakpoint addedBreakpoint = AddBreakpoint(fileName, line, column);
// Check if it wasn't forced to move to different line with breakpoint
foreach (Breakpoint breakpoint in Breakpoints) {
if (breakpoint != addedBreakpoint) { // Only the old ones
if (breakpoint.SourcecodeSegment.StartLine == addedBreakpoint.SourcecodeSegment.StartLine) {
// Whops! We have two breakpoint on signle line, delete one
Breakpoints.Remove(addedBreakpoint);
RemoveBreakpoint(addedBreakpoint);
return;
}
}

101
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/ModuleCollection.cs

@ -1,101 +0,0 @@ @@ -1,101 +0,0 @@
// <file>
// <owner name="David Srbecký" email="dsrbecky@post.cz"/>
// </file>
using System;
using System.Collections;
using DebuggerInterop.Core;
namespace DebuggerLibrary
{
public class ModuleCollection: ReadOnlyCollectionBase
{
int lastAssignedOrderOfLoading= 0;
public event ModuleEventHandler ModuleAdded;
private void OnModuleAdded(Module module)
{
if (ModuleAdded != null)
ModuleAdded(this, new ModuleEventArgs(module));
}
public event ModuleEventHandler ModuleRemoved;
private void OnModuleRemoved(Module module)
{
if (ModuleRemoved != null)
ModuleRemoved(this, new ModuleEventArgs(module));
}
public Module this[int index] {
get {
return (Module) InnerList[index];
}
}
public Module this[string filename] {
get {
foreach(Module module in InnerList)
if (module.Filename == filename)
return module;
throw new UnableToGetPropertyException(this, "this[string]", "Module \"" + filename + "\" is not in collection");
}
}
internal Module this[ICorDebugModule corModule]
{
get
{
foreach(Module module in InnerList)
if (module.CorModule == corModule)
return module;
throw new UnableToGetPropertyException(this, "this[ICorDebugModule]", "Module is not in collection");
}
}
internal void Clear()
{
foreach (Module m in InnerList) {
OnModuleRemoved(m);
}
InnerList.Clear();
lastAssignedOrderOfLoading = 0;
}
internal void Add(Module module)
{
System.Diagnostics.Trace.Assert(module != null);
if (module != null)
{
module.OrderOfLoading = lastAssignedOrderOfLoading;
lastAssignedOrderOfLoading++;
InnerList.Add(module);
OnModuleAdded(module);
}
}
internal void Add(ICorDebugModule corModule)
{
System.Diagnostics.Trace.Assert(corModule != null);
if (corModule != null)
Add(new Module(corModule));
}
internal void Remove(Module module)
{
InnerList.Remove(module);
OnModuleRemoved (module);
}
internal void Remove(ICorDebugModule corModule)
{
Remove(this[corModule]);
}
}
}

96
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Modules/NDebugger-Modules.cs

@ -0,0 +1,96 @@ @@ -0,0 +1,96 @@
// <file>
// <owner name="David Srbecký" email="dsrbecky@post.cz"/>
// </file>
using System;
using System.Collections.Generic;
using DebuggerInterop.Core;
namespace DebuggerLibrary
{
public partial class NDebugger
{
int lastAssignedModuleOrderOfLoading= 0;
List<Module> moduleCollection = new List<Module>();
public event ModuleEventHandler ModuleLoaded;
public event ModuleEventHandler ModuleUnloaded;
protected void OnModuleLoaded(Module module)
{
if (ModuleLoaded != null) {
ModuleLoaded(this, new ModuleEventArgs(module));
}
}
protected void OnModuleUnloaded(Module module)
{
if (ModuleUnloaded != null) {
ModuleUnloaded(this, new ModuleEventArgs(module));
}
}
public IList<Module> Modules {
get{
return moduleCollection.AsReadOnly();
}
}
public Module GetModule(string filename)
{
foreach(Module module in moduleCollection) {
if (module.Filename == filename) {
return module;
}
}
throw new UnableToGetPropertyException(this, "GetModule(string filename)", "Module \"" + filename + "\" is not in collection");
}
internal Module GetModule(ICorDebugModule corModule)
{
foreach(Module module in moduleCollection) {
if (module.CorModule == corModule) {
return module;
}
}
throw new UnableToGetPropertyException(this, "GetModule(ICorDebugModule corModule)", "Module is not in collection");
}
internal void AddModule(Module module)
{
module.OrderOfLoading = lastAssignedModuleOrderOfLoading;
lastAssignedModuleOrderOfLoading++;
moduleCollection.Add(module);
OnModuleLoaded(module);
}
internal void AddModule(ICorDebugModule corModule)
{
AddModule(new Module(corModule));
}
internal void RemoveModule(Module module)
{
moduleCollection.Remove(module);
OnModuleUnloaded(module);
}
internal void RemoveModule(ICorDebugModule corModule)
{
RemoveModule(GetModule(corModule));
}
internal void ClearModules()
{
foreach (Module m in moduleCollection) {
OnModuleUnloaded(m);
}
moduleCollection.Clear();
lastAssignedModuleOrderOfLoading = 0;
}
}
}

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

@ -44,7 +44,7 @@ namespace DebuggerLibrary @@ -44,7 +44,7 @@ namespace DebuggerLibrary
this.token = new SymbolToken((int)functionToken);
ICorDebugModule corModule;
corFunction.GetModule(out corModule);
module = NDebugger.Modules[corModule];
module = NDebugger.Instance.GetModule(corModule);
Init();
}

39
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/FunctionCollection.cs

@ -1,39 +0,0 @@ @@ -1,39 +0,0 @@
// <file>
// <owner name="David Srbecký" email="dsrbecky@post.cz"/>
// </file>
using System;
using System.Collections;
using System.Diagnostics;
using DebuggerInterop.Core;
namespace DebuggerLibrary
{
public class FunctionCollection: ReadOnlyCollectionBase
{
internal void Add(Function function)
{
System.Diagnostics.Trace.Assert(function != null);
if (function != null)
InnerList.Add(function);
}
public Function this[int index] {
get {
return (Function) InnerList[index];
}
}
public Function this[string functionName]
{
get {
foreach (Function f in InnerList)
if (f.Name == functionName)
return f;
throw new UnableToGetPropertyException(this, "this[string]", "Function \"" + functionName + "\" is not in collection");
}
}
}
}

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

@ -0,0 +1,89 @@ @@ -0,0 +1,89 @@
// <file>
// <owner name="David Srbecký" email="dsrbecky@post.cz"/>
// </file>
using System;
using System.Collections.Generic;
using DebuggerInterop.Core;
namespace DebuggerLibrary
{
public partial class NDebugger
{
List<Thread> threadCollection = new List<Thread>();
public event ThreadEventHandler ThreadStarted;
public event ThreadEventHandler ThreadExited;
public event ThreadEventHandler ThreadStateChanged;
protected void OnThreadStarted(Thread thread)
{
if (ThreadStarted != null) {
ThreadStarted(this, new ThreadEventArgs(thread));
}
}
protected void OnThreadExited(Thread thread)
{
if (ThreadExited != null) {
ThreadExited(this, new ThreadEventArgs(thread));
}
}
protected void OnThreadStateChanged(object sender, ThreadEventArgs e)
{
if (ThreadStateChanged != null) {
ThreadStateChanged(this, new ThreadEventArgs(e.Thread));
}
}
public IList<Thread> Threads {
get {
return threadCollection.AsReadOnly();
}
}
internal Thread GetThread(ICorDebugThread corThread)
{
foreach(Thread thread in threadCollection) {
if (thread.CorThread == corThread) {
return thread;
}
}
throw new UnableToGetPropertyException(this, "this[ICorDebugThread]", "Thread is not in collection");
}
internal void AddThread(Thread thread)
{
threadCollection.Add(thread);
thread.ThreadStateChanged += new ThreadEventHandler(OnThreadStateChanged);
OnThreadStarted(thread);
}
internal void AddThread(ICorDebugThread corThread)
{
AddThread(new Thread(corThread));
}
internal void RemoveThread(Thread thread)
{
threadCollection.Remove(thread);
thread.ThreadStateChanged -= new ThreadEventHandler(OnThreadStateChanged);
OnThreadExited(thread);
}
internal void RemoveThread(ICorDebugThread corThread)
{
RemoveThread(GetThread(corThread));
}
internal void ClearThreads()
{
foreach (Thread t in threadCollection) {
RemoveThread(t);
}
}
}
}

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

@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
// </file>
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading;
@ -11,7 +12,7 @@ using DebuggerInterop.MetaData; @@ -11,7 +12,7 @@ using DebuggerInterop.MetaData;
namespace DebuggerLibrary
{
public class Thread
public partial class Thread
{
internal bool currentExceptionIsHandled;
@ -125,9 +126,9 @@ namespace DebuggerLibrary @@ -125,9 +126,9 @@ namespace DebuggerLibrary
}
}
public unsafe FunctionCollection Callstack {
public unsafe List<Function> Callstack {
get {
FunctionCollection callstack = new FunctionCollection();
List<Function> callstack = new List<Function>();
if (!NDebugger.IsDebugging) return callstack;
if (NDebugger.IsProcessRunning) return callstack;
@ -171,7 +172,7 @@ namespace DebuggerLibrary @@ -171,7 +172,7 @@ namespace DebuggerLibrary
ICorDebugFrame corFrame;
corThread.GetActiveFrame(out corFrame);
if (corFrame == null) {
FunctionCollection callstack = Callstack;
List<Function> callstack = Callstack;
if (callstack.Count > 0) {
return callstack[0];
} else {

103
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/ThreadCollection.cs

@ -1,103 +0,0 @@ @@ -1,103 +0,0 @@
// <file>
// <owner name="David Srbecký" email="dsrbecky@post.cz"/>
// </file>
using System;
using System.Collections;
using DebuggerInterop.Core;
namespace DebuggerLibrary
{
public class ThreadCollection: ReadOnlyCollectionBase
{
internal ThreadCollection()
{
}
public event ThreadEventHandler ThreadAdded;
private void OnThreadAdded(Thread thread)
{
thread.ThreadStateChanged += new ThreadEventHandler(OnThreadStateChanged);
if (ThreadAdded != null)
ThreadAdded(this, new ThreadEventArgs(thread));
}
public event ThreadEventHandler ThreadRemoved;
private void OnThreadRemoved(Thread thread)
{
thread.ThreadStateChanged -= new ThreadEventHandler(OnThreadStateChanged);
if (ThreadRemoved != null)
ThreadRemoved(this, new ThreadEventArgs(thread));
}
public event ThreadEventHandler ThreadStateChanged;
private void OnThreadStateChanged(object sender, ThreadEventArgs e)
{
if (ThreadStateChanged != null)
ThreadStateChanged(this, new ThreadEventArgs(e.Thread));
}
public Thread this[int index] {
get {
return (Thread) InnerList[index];
}
}
internal Thread this[ICorDebugThread corThread]
{
get
{
foreach(Thread thread in InnerList)
if (thread.CorThread == corThread)
return thread;
throw new UnableToGetPropertyException(this, "this[ICorDebugThread]", "Thread is not in collection");
}
}
internal void Clear()
{
foreach (Thread t in InnerList) {
OnThreadRemoved(t);
}
InnerList.Clear();
}
internal void Add(Thread thread)
{
System.Diagnostics.Trace.Assert(thread != null);
if (thread != null)
{
InnerList.Add(thread);
OnThreadAdded(thread);
}
}
internal void Add(ICorDebugThread corThread)
{
System.Diagnostics.Trace.Assert(corThread != null);
if (corThread != null)
Add(new Thread(corThread));
}
internal void Remove(Thread thread)
{
InnerList.Remove(thread);
OnThreadRemoved(thread);
}
internal void Remove(ICorDebugThread corThread)
{
Remove(this[corThread]);
}
}
}

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

@ -145,7 +145,7 @@ namespace DebuggerLibrary @@ -145,7 +145,7 @@ namespace DebuggerLibrary
fullTypeName = NDebugger.pStringAsUnicode;
superCallsToken = 0;
foreach (Module m in NDebugger.Modules)
foreach (Module m in NDebugger.Instance.Modules)
{
// TODO: Does not work for nested
// see FindTypeDefByName in dshell.cpp

Loading…
Cancel
Save