Browse Source

Fix SD-1753 - Attach to process dialog shows no managed processes after attaching to one process

pull/14/head
Eusebiu Marcu 15 years ago
parent
commit
b7b7c5cf6b
  1. 1
      src/AddIns/Debugger/Debugger.AddIn/Service/AttachToProcessForm.cs
  2. 7
      src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs
  3. 6
      src/AddIns/Debugger/Debugger.Core/NDebugger.cs
  4. 20
      src/AddIns/Debugger/Debugger.Core/Process.cs

1
src/AddIns/Debugger/Debugger.AddIn/Service/AttachToProcessForm.cs

@ -57,6 +57,7 @@ namespace ICSharpCode.SharpDevelop.Services
Process currentProcess = Process.GetCurrentProcess(); Process currentProcess = Process.GetCurrentProcess();
foreach (Process process in Process.GetProcesses()) { foreach (Process process in Process.GetProcesses()) {
try { try {
if (process.HasExited) continue;
// Prevent attaching to our own process. // Prevent attaching to our own process.
if (currentProcess.Id != process.Id) { if (currentProcess.Id != process.Id) {
ProcessListViewItem item = new ProcessListViewItem(process, debugger); ProcessListViewItem item = new ProcessListViewItem(process, debugger);

7
src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs

@ -13,6 +13,7 @@ using System.Windows.Forms;
using Debugger; using Debugger;
using Debugger.AddIn; using Debugger.AddIn;
using Debugger.AddIn.TreeModel; using Debugger.AddIn.TreeModel;
using Debugger.Interop;
using Debugger.Interop.CorPublish; using Debugger.Interop.CorPublish;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.Core.WinForms; using ICSharpCode.Core.WinForms;
@ -362,10 +363,8 @@ namespace ICSharpCode.SharpDevelop.Services
public bool IsManaged(int processId) public bool IsManaged(int processId)
{ {
if (corPublish == null) { corPublish = new CorpubPublishClass();
corPublish = new CorpubPublishClass(); Debugger.Interop.TrackedComObjects.Track(corPublish);
Debugger.Interop.TrackedComObjects.Track(corPublish);
}
ICorPublishProcess process = corPublish.GetProcess((uint)processId); ICorPublishProcess process = corPublish.GetProcess((uint)processId);
if (process != null) { if (process != null) {

6
src/AddIns/Debugger/Debugger.Core/NDebugger.cs

@ -212,8 +212,10 @@ namespace Debugger
} }
// Detach all processes. // Detach all processes.
while (this.Processes.Count > 0) { for (int i = 0; i < this.Processes.Count; ++i) {
Process process = this.Processes[0]; Process process = this.Processes[i];
if (process == null || process.HasExited)
continue;
process.Detach(); process.Detach();
} }
} }

20
src/AddIns/Debugger/Debugger.Core/Process.cs

@ -3,10 +3,12 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices;
using Debugger.Interop;
using Debugger.Interop.CorDebug; using Debugger.Interop.CorDebug;
using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Visitors; using ICSharpCode.NRefactory.Visitors;
using System.Runtime.InteropServices;
namespace Debugger namespace Debugger
{ {
@ -400,6 +402,7 @@ namespace Debugger
corProcess.Stop(uint.MaxValue); corProcess.Stop(uint.MaxValue);
NotifyPaused(PausedReason.ForcedBreak); NotifyPaused(PausedReason.ForcedBreak);
} }
// This is necessary for detach // This is necessary for detach
foreach(Stepper s in this.Steppers) { foreach(Stepper s in this.Steppers) {
if (s.CorStepper.IsActive() == 1) { if (s.CorStepper.IsActive() == 1) {
@ -407,8 +410,21 @@ namespace Debugger
} }
} }
this.Steppers.Clear(); this.Steppers.Clear();
corProcess.Detach(); corProcess.Detach();
NotifyHasExited();
// modules
foreach(Module m in this.Modules)
{
m.Dispose();
}
this.modules.Clear();
// threads
this.threads.Clear();
NotifyHasExited();
} }
public void Continue() public void Continue()

Loading…
Cancel
Save