Browse Source

Added Process collection

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@202 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
David Srbecký 21 years ago
parent
commit
65171699b3
  1. 15
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs
  2. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj
  3. 14
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/Internal/ManagedCallback.cs
  4. 56
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Debugger/NDebugger.cs
  5. 71
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/NDebugger-Processes.cs
  6. 2
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/Process.cs
  7. 27
      src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/ProcessEventHandler.cs

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

@ -172,10 +172,10 @@ namespace ICSharpCode.SharpDevelop.Services @@ -172,10 +172,10 @@ namespace ICSharpCode.SharpDevelop.Services
debugger.DebuggerTraceMessage += new MessageEventHandler(DebuggerTraceMessage);
debugger.LogMessage += new MessageEventHandler(LogMessage);
debugger.DebuggingStarted += new DebuggerEventHandler(DebuggingStarted);
debugger.ProcessStarted += new ProcessEventHandler(ProcessStarted);
debugger.DebuggingPaused += new DebuggingPausedEventHandler(DebuggingPaused);
debugger.DebuggingResumed += new DebuggerEventHandler(DebuggingResumed);
debugger.DebuggingStopped += new DebuggerEventHandler(DebuggingStopped);
debugger.ProcessExited += new ProcessEventHandler(ProcessExited);
debugger.IsDebuggingChanged += new DebuggerEventHandler(OnIsDebuggingChanged);
debugger.IsProcessRunningChanged += new DebuggerEventHandler(DebuggerStateChanged);
debugger.BreakpointStateChanged += new DebuggerLibrary.BreakpointEventHandler(RestoreSharpdevelopBreakpoint);
@ -200,10 +200,10 @@ namespace ICSharpCode.SharpDevelop.Services @@ -200,10 +200,10 @@ namespace ICSharpCode.SharpDevelop.Services
{
debugger.DebuggerTraceMessage -= new MessageEventHandler(DebuggerTraceMessage);
debugger.LogMessage -= new MessageEventHandler(LogMessage);
debugger.DebuggingStarted -= new DebuggerEventHandler(DebuggingStarted);
debugger.ProcessStarted -= new ProcessEventHandler(ProcessStarted);
debugger.DebuggingPaused -= new DebuggingPausedEventHandler(DebuggingPaused);
debugger.DebuggingResumed -= new DebuggerEventHandler(DebuggingResumed);
debugger.DebuggingStopped -= new DebuggerEventHandler(DebuggingStopped);
debugger.ProcessExited -= new ProcessEventHandler(ProcessExited);
debugger.IsDebuggingChanged -= new DebuggerEventHandler(OnIsDebuggingChanged);
debugger.IsProcessRunningChanged -= new DebuggerEventHandler(DebuggerStateChanged);
debugger.BreakpointStateChanged -= new DebuggerLibrary.BreakpointEventHandler(RestoreSharpdevelopBreakpoint);
@ -332,7 +332,7 @@ namespace ICSharpCode.SharpDevelop.Services @@ -332,7 +332,7 @@ namespace ICSharpCode.SharpDevelop.Services
}
}
void DebuggingStarted(object sender, DebuggerEventArgs e)
void ProcessStarted(object sender, ProcessEventArgs e)
{
// Initialize
/*PadDescriptor cmv = (CompilerMessageView)WorkbenchSingleton.Workbench.GetPad(typeof(CompilerMessageView));
@ -387,10 +387,11 @@ namespace ICSharpCode.SharpDevelop.Services @@ -387,10 +387,11 @@ namespace ICSharpCode.SharpDevelop.Services
DebuggerService.RemoveCurrentLineMarker();
}
void DebuggingStopped(object sender, DebuggerEventArgs e)
void ProcessExited(object sender, ProcessEventArgs e)
{
if (debugger.Processes.Count == 0) {
exceptionHistory.Clear();
//DebuggerService.Stop();//TODO: delete
}
}
public void JumpToCurrentLine()

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

@ -73,8 +73,10 @@ @@ -73,8 +73,10 @@
<Compile Include="Src\Threads\Exception.cs" />
<Compile Include="Src\Threads\ExceptionType.cs" />
<Compile Include="Src\Threads\Function.cs" />
<Compile Include="Src\Threads\NDebugger-Processes.cs" />
<Compile Include="Src\Threads\NDebugger-Threads.cs" />
<Compile Include="Src\Threads\Process.cs" />
<Compile Include="Src\Threads\ProcessEventHandler.cs" />
<Compile Include="Src\Threads\SourcecodeSegment.cs" />
<Compile Include="Src\Threads\Thread.cs" />
<Compile Include="Src\Threads\ThreadEventHandler.cs" />

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

@ -300,8 +300,9 @@ namespace DebuggerLibrary @@ -300,8 +300,9 @@ namespace DebuggerLibrary
Thread thread = debugger.GetThread(pThread);
if (debugger.CurrentThread == thread)
if (debugger.CurrentThread == thread) {
debugger.CurrentThread = null;
}
debugger.RemoveThread(thread);
@ -319,8 +320,17 @@ namespace DebuggerLibrary @@ -319,8 +320,17 @@ namespace DebuggerLibrary
{
EnterCallback("ExitProcess");
debugger.ResetEnvironment();
Process process = debugger.GetProcess(pProcess);
if (debugger.CurrentProcess == process) {
debugger.CurrentProcess = null;
}
debugger.RemoveProcess(process);
if (debugger.Processes.Count == 0) {
debugger.ResetEnvironment();
}
}
#endregion

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

@ -11,6 +11,7 @@ using System.Threading; @@ -11,6 +11,7 @@ using System.Threading;
using DebuggerInterop.Core;
using DebuggerInterop.MetaData;
using System.Collections.Generic;
namespace DebuggerLibrary
{
@ -20,8 +21,6 @@ namespace DebuggerLibrary @@ -20,8 +21,6 @@ namespace DebuggerLibrary
ManagedCallback managedCallback;
ManagedCallbackProxy managedCallbackProxy;
Process mainProcess;
public bool CatchHandledExceptions = false;
ApartmentState requiredApartmentState;
@ -46,27 +45,6 @@ namespace DebuggerLibrary @@ -46,27 +45,6 @@ namespace DebuggerLibrary
}
}
internal Process CurrentProcess {
get {
return mainProcess;
}
set {
if (mainProcess == value) return;
mainProcess = value;
if (value != null) {
OnDebuggingStarted();
OnIsDebuggingChanged();
OnIsProcessRunningChanged();
} else {
//OnDebuggingPaused(PausedReason.ProcessExited);
OnIsProcessRunningChanged();
OnDebuggingStopped();
OnIsDebuggingChanged();
}
}
}
internal ManagedCallback ManagedCallback {
get {
return managedCallback;
@ -115,7 +93,10 @@ namespace DebuggerLibrary @@ -115,7 +93,10 @@ namespace DebuggerLibrary
ClearThreads();
CurrentProcess = null;
OnIsProcessRunningChanged();
OnIsDebuggingChanged();
currentProcess = null;
evalQueue = new EvalQueue();
@ -128,17 +109,6 @@ namespace DebuggerLibrary @@ -128,17 +109,6 @@ namespace DebuggerLibrary
#region Public events
public event DebuggerEventHandler DebuggingStarted;
protected internal virtual void OnDebuggingStarted()
{
TraceMessage ("Debugger event: OnDebuggingStarted()");
if (DebuggingStarted != null) {
DebuggingStarted(null, new DebuggerEventArgs());
}
}
public event DebuggingPausedEventHandler DebuggingPaused;
protected internal virtual void OnDebuggingPaused(PausedReason reason)
@ -183,17 +153,6 @@ namespace DebuggerLibrary @@ -183,17 +153,6 @@ namespace DebuggerLibrary
}
public event DebuggerEventHandler DebuggingStopped;
protected internal virtual void OnDebuggingStopped()
{
TraceMessage ("Debugger event: OnDebuggingStopped()");
if (DebuggingStopped != null) {
DebuggingStopped(null, new DebuggerEventArgs());
}
}
public event DebuggerEventHandler IsProcessRunningChanged;
protected internal virtual void OnIsProcessRunningChanged()
@ -267,7 +226,10 @@ namespace DebuggerLibrary @@ -267,7 +226,10 @@ namespace DebuggerLibrary
public void Start(string filename, string workingDirectory, string arguments)
{
CurrentProcess = Process.CreateProcess(this, filename, workingDirectory, arguments);
Process process = Process.CreateProcess(this, filename, workingDirectory, arguments);
AddProcess(process);
OnIsDebuggingChanged();
OnIsProcessRunningChanged();
}

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

@ -0,0 +1,71 @@ @@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Text;
using DebuggerInterop.Core;
namespace DebuggerLibrary
{
public partial class NDebugger
{
List<Process> processCollection = new List<Process>();
Process currentProcess;
public event ProcessEventHandler ProcessStarted;
public event ProcessEventHandler ProcessExited;
public Process CurrentProcess {
get {
if (currentProcess == null && Processes.Count > 0) {
currentProcess = Processes[0];
}
return currentProcess;
}
set {
currentProcess = value;
}
}
public IList<Process> Processes {
get {
return processCollection.AsReadOnly();
}
}
internal Process GetProcess(ICorDebugProcess corProcess)
{
foreach (Process process in Processes) {
if (process.CorProcess == corProcess) {
return process;
}
}
throw new DebuggerException("Process not found");
}
internal void AddProcess(Process process)
{
processCollection.Add(process);
OnProcessStarted(process);
}
internal void RemoveProcess(Process process)
{
processCollection.Remove(process);
OnProcessExited(process);
}
protected virtual void OnProcessStarted(Process process)
{
if (ProcessStarted != null) {
ProcessStarted(this, new ProcessEventArgs(process));
}
}
protected virtual void OnProcessExited(Process process)
{
if (ProcessExited != null) {
ProcessExited(this, new ProcessEventArgs(process));
}
}
}
}

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

@ -19,7 +19,7 @@ namespace DebuggerLibrary @@ -19,7 +19,7 @@ namespace DebuggerLibrary
ICorDebugProcess corProcess;
Thread currentThread;
bool isProcessRunning;
bool isProcessRunning = true;
internal Process(NDebugger debugger, ICorDebugProcess corProcess)
{

27
src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Threads/ProcessEventHandler.cs

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
// <file>
// <owner name="David Srbecký" email="dsrbecky@post.cz"/>
// </file>
using System;
namespace DebuggerLibrary
{
public delegate void ProcessEventHandler (object sender, ProcessEventArgs args);
[Serializable]
public class ProcessEventArgs: EventArgs
{
Process process;
public Process Process {
get {
return process;
}
}
public ProcessEventArgs(Process process)
{
this.process = process;
}
}
}
Loading…
Cancel
Save