diff --git a/data/resources/StringResources.nl.resources b/data/resources/StringResources.nl.resources index 8a2d5dfcf9..9e4b467133 100644 Binary files a/data/resources/StringResources.nl.resources and b/data/resources/StringResources.nl.resources differ diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj index 860e03ffee..60cc25a637 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Debugger.AddIn.csproj @@ -60,6 +60,7 @@ + Form diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/AttachToProcessForm.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/AttachToProcessForm.cs new file mode 100644 index 0000000000..b083acd500 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/AttachToProcessForm.cs @@ -0,0 +1,78 @@ +// +// +// +// $Revision$ +// + +using System; +using System.ComponentModel; +using System.Diagnostics; +using System.IO; +using System.Windows.Forms; +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Debugging; +using ICSharpCode.SharpDevelop.Gui; + +namespace ICSharpCode.SharpDevelop.Services +{ + public class AttachToProcessForm : AbstractAttachToProcessForm + { + class ProcessListViewItem : ListViewItem + { + Process process; + bool managed; + + public ProcessListViewItem(Process process, WindowsDebugger debugger) + { + this.process = process; + try { + managed = debugger.IsManaged(process.Id); + } catch { } + + string fileName = Path.GetFileName(process.MainModule.FileName); + Text = fileName; + SubItems.Add(process.Id.ToString()); + SubItems.Add(process.MainWindowTitle); + SubItems.Add(GetManagedString(managed)); + } + + public Process Process { + get { return process; } + } + + public bool IsManaged { + get { return managed; } + } + + static string GetManagedString(bool managed) + { + if (managed) { + return StringParser.Parse("${res:ICSharpCode.SharpDevelop.Gui.Dialogs.AttachToProcessForm.Managed}"); + } + return String.Empty; + } + } + + protected override void RefreshProcessList(ListView listView, bool showNonManaged) + { + listView.Items.Clear(); + WindowsDebugger debugger = (WindowsDebugger)DebuggerService.CurrentDebugger; + Process currentProcess = Process.GetCurrentProcess(); + foreach (System.Diagnostics.Process process in System.Diagnostics.Process.GetProcesses()) { + try { + // Prevent attaching to our own process. + if (currentProcess.Id != process.Id) { + ProcessListViewItem item = new ProcessListViewItem(process, debugger); + if (showNonManaged || item.IsManaged) { + item.Tag = process; + listView.Items.Add(item); + } + } + } catch (Win32Exception) { + // Do nothing. + } + } + listView.Sort(); + } + } +} diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs index 71395ae354..c4a5c35e71 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs @@ -46,6 +46,7 @@ using Bitmap = System.Drawing.Bitmap; using Debugger; using Debugger.Expressions; using Debugger.AddIn.TreeModel; +using Debugger.Core.Wrappers.CorPub; using ICSharpCode.Core; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Project; @@ -60,6 +61,8 @@ namespace ICSharpCode.SharpDevelop.Services NDebugger debugger; + ICorPublish corPublish; + Debugger.Process debuggedProcess; DynamicTreeDebuggerRow currentTooltipRow; @@ -152,6 +155,15 @@ namespace ICSharpCode.SharpDevelop.Services } } + public void ShowAttachDialog() + { + using (AttachToProcessForm attachForm = new AttachToProcessForm()) { + if (attachForm.ShowDialog() == DialogResult.OK) { + Attach(attachForm.Process); + } + } + } + public void Attach(System.Diagnostics.Process existingProcess) { if (IsDebugging) { @@ -292,6 +304,18 @@ namespace ICSharpCode.SharpDevelop.Services } } + public bool IsManaged(int processId) + { + if (corPublish == null) { + corPublish = new ICorPublish(); + } + + ICorPublishProcess process = corPublish.GetProcess(processId); + if (process != null) { + return process.IsManaged; + } + return false; + } /// /// Gets the current value of the variable as string that can be displayed in tooltips. 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 cfc3d53c84..ca9150ac90 100644 --- a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Debugger.Core.csproj @@ -324,6 +324,16 @@ + + + + + + + + + + @@ -390,9 +400,11 @@ + + \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/CorPublishClass.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/CorPublishClass.cs new file mode 100644 index 0000000000..faed26729f --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/CorPublishClass.cs @@ -0,0 +1,60 @@ +// +// +// +// +// $Revision$ +// + +#pragma warning disable 108, 1591 + +namespace Debugger.Interop.CorPub +{ + using System; + using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; + using System.Text; + + [ComImport, TypeLibType((short) 2), ClassInterface((short) 0), Guid("047A9A40-657E-11D3-8D5B-00104B35E7EF")] + public class CorpubPublishClass : ICorPublish, CorpubPublish, ICorPublishProcess, ICorPublishAppDomain, ICorPublishProcessEnum, ICorPublishAppDomainEnum + { + // Methods + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void Clone([MarshalAs(UnmanagedType.Interface)] out ICorPublishEnum ppEnum); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void EnumAppDomains([MarshalAs(UnmanagedType.Interface)] out ICorPublishAppDomainEnum ppEnum); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void EnumProcesses([In, ComAliasName("CorpubProcessLib.COR_PUB_ENUMPROCESS")] COR_PUB_ENUMPROCESS Type, [MarshalAs(UnmanagedType.Interface)] out ICorPublishProcessEnum ppIEnum); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void GetCount(out uint pcelt); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void GetDisplayName([In] uint cchName, out uint pcchName, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder szName); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void GetID(out uint puId); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void GetName([In] uint cchName, out uint pcchName, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder szName); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void GetProcess([In] uint pid, [MarshalAs(UnmanagedType.Interface)] out ICorPublishProcess ppProcess); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void GetProcessID(out uint pid); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void ICorPublishAppDomainEnum_Clone([MarshalAs(UnmanagedType.Interface)] out ICorPublishEnum ppEnum); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void ICorPublishAppDomainEnum_GetCount(out uint pcelt); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void ICorPublishAppDomainEnum_Reset(); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void ICorPublishAppDomainEnum_Skip([In] uint celt); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void IsManaged(out int pbManaged); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out ICorPublishAppDomain objects, out uint pceltFetched); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out ICorPublishProcess objects, out uint pceltFetched); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void Reset(); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + public virtual extern void Skip([In] uint celt); + } +} + +#pragma warning restore 108, 1591 \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/CorpubPublish.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/CorpubPublish.cs new file mode 100644 index 0000000000..245cb91d28 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/CorpubPublish.cs @@ -0,0 +1,23 @@ +// +// +// +// +// $Revision$ +// + +#pragma warning disable 108, 1591 + +namespace Debugger.Interop.CorPub +{ + using System; + using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; + + [ComImport, CoClass(typeof(CorpubPublishClass)), Guid("9613A0E7-5A68-11D3-8F84-00A0C9B4D50C")] + public interface CorpubPublish : ICorPublish + { + } +} + +#pragma warning restore 108, 1591 + diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublish.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublish.cs new file mode 100644 index 0000000000..4aa6d130ea --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublish.cs @@ -0,0 +1,31 @@ +// +// +// +// +// $Revision$ +// + +#pragma warning disable 108, 1591 + +namespace Debugger.Interop.CorPub +{ + using System; + using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; + + public enum COR_PUB_ENUMPROCESS + { + COR_PUB_MANAGEDONLY = 1 + } + + [ComImport, Guid("9613A0E7-5A68-11D3-8F84-00A0C9B4D50C"), InterfaceType((short) 1)] + public interface ICorPublish + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void EnumProcesses([In, ComAliasName("CorpubProcessLib.COR_PUB_ENUMPROCESS")] COR_PUB_ENUMPROCESS Type, [MarshalAs(UnmanagedType.Interface)] out ICorPublishProcessEnum ppIEnum); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void GetProcess([In] uint pid, [MarshalAs(UnmanagedType.Interface)] out ICorPublishProcess ppProcess); + } +} + +#pragma warning restore 108, 1591 \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishAppDomain.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishAppDomain.cs new file mode 100644 index 0000000000..8705584de4 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishAppDomain.cs @@ -0,0 +1,27 @@ +// +// +// +// +// $Revision$ +// + +#pragma warning disable 108, 1591 + +namespace Debugger.Interop.CorPub +{ + using System; + using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; + using System.Text; + + [ComImport, Guid("D6315C8F-5A6A-11D3-8F84-00A0C9B4D50C"), InterfaceType((short) 1)] + public interface ICorPublishAppDomain + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void GetID(out uint puId); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void GetName([In] uint cchName, out uint pcchName, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder szName); + } +} + +#pragma warning restore 108, 1591 \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishAppDomainEnum.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishAppDomainEnum.cs new file mode 100644 index 0000000000..4ed89845f7 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishAppDomainEnum.cs @@ -0,0 +1,35 @@ +// +// +// +// +// $Revision$ +// + +#pragma warning disable 108, 1591 + +namespace Debugger.Interop.CorPub +{ + using System; + using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; + + [ComImport, Guid("9F0C98F5-5A6A-11D3-8F84-00A0C9B4D50C"), InterfaceType((short) 1),] + public interface ICorPublishAppDomainEnum : ICorPublishEnum + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void Skip([In] uint celt); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void Reset(); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void Clone([MarshalAs(UnmanagedType.Interface)] out ICorPublishEnum ppEnum); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void GetCount(out uint pcelt); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out ICorPublishAppDomain objects, out uint pceltFetched); + } +} + +#pragma warning restore 108, 1591 + + + diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishEnum.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishEnum.cs new file mode 100644 index 0000000000..6fe2c0fa57 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishEnum.cs @@ -0,0 +1,30 @@ +// +// +// +// +// $Revision$ +// + +#pragma warning disable 108, 1591 + +namespace Debugger.Interop.CorPub +{ + using System; + using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; + + [ComImport, Guid("C0B22967-5A69-11D3-8F84-00A0C9B4D50C"), InterfaceType((short) 1)] + public interface ICorPublishEnum + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void Skip([In] uint celt); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void Reset(); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void Clone([MarshalAs(UnmanagedType.Interface)] out ICorPublishEnum ppEnum); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void GetCount(out uint pcelt); + } +} + +#pragma warning restore 108, 1591 diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishProcess.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishProcess.cs new file mode 100644 index 0000000000..426c36496b --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishProcess.cs @@ -0,0 +1,31 @@ +// +// +// +// +// $Revision$ +// + +#pragma warning disable 108, 1591 + +namespace Debugger.Interop.CorPub +{ + using System; + using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; + using System.Text; + + [ComImport, Guid("18D87AF1-5A6A-11D3-8F84-00A0C9B4D50C"), InterfaceType((short) 1)] + public interface ICorPublishProcess + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void IsManaged(out int pbManaged); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void EnumAppDomains([MarshalAs(UnmanagedType.Interface)] out ICorPublishAppDomainEnum ppEnum); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void GetProcessID(out uint pid); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void GetDisplayName([In] uint cchName, out uint pcchName, [Out, MarshalAs(UnmanagedType.LPWStr)] StringBuilder szName); + } +} + +#pragma warning restore 108, 1591 \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishProcessEnum.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishProcessEnum.cs new file mode 100644 index 0000000000..9b6390291c --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/Autogenerated/ICorPublishProcessEnum.cs @@ -0,0 +1,32 @@ +// +// +// +// +// $Revision$ +// + +#pragma warning disable 108, 1591 + +namespace Debugger.Interop.CorPub +{ + using System; + using System.Runtime.CompilerServices; + using System.Runtime.InteropServices; + + [ComImport, Guid("A37FBD41-5A69-11D3-8F84-00A0C9B4D50C"), InterfaceType((short) 1)] + public interface ICorPublishProcessEnum : ICorPublishEnum + { + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void Skip([In] uint celt); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void Reset(); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void Clone([MarshalAs(UnmanagedType.Interface)] out ICorPublishEnum ppEnum); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void GetCount(out uint pcelt); + [MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)] + void Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out ICorPublishProcess objects, out uint pceltFetched); + } +} + +#pragma warning restore 108, 1591 \ No newline at end of file diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/ICorPublish.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/ICorPublish.cs new file mode 100644 index 0000000000..831bed18ae --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/ICorPublish.cs @@ -0,0 +1,34 @@ +// +// +// +// +// $Revision$ +// + +#pragma warning disable 1591 + +namespace Debugger.Core.Wrappers.CorPub +{ + using System; + using System.Runtime.InteropServices; + using Debugger.Wrappers; + + public partial class ICorPublish + { + private Debugger.Interop.CorPub.CorpubPublishClass corpubPublishClass; + + public ICorPublish() + { + corpubPublishClass = new Debugger.Interop.CorPub.CorpubPublishClass(); + } + + public ICorPublishProcess GetProcess(int id) + { + Debugger.Interop.CorPub.ICorPublishProcess process; + this.corpubPublishClass.GetProcess((uint)id, out process); + return ICorPublishProcess.Wrap(process); + } + } +} + +#pragma warning restore 1591 diff --git a/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/ICorPublishProcess.cs b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/ICorPublishProcess.cs new file mode 100644 index 0000000000..3fb2d6f7d3 --- /dev/null +++ b/src/AddIns/Misc/Debugger/Debugger.Core/Project/Src/Wrappers/CorPub/ICorPublishProcess.cs @@ -0,0 +1,68 @@ +// +// +// +// +// $Revision$ +// + +#pragma warning disable 1591 + +namespace Debugger.Core.Wrappers.CorPub +{ + using System; + using System.Runtime.InteropServices; + using System.Text; + using Debugger.Wrappers; + + public partial class ICorPublishProcess + { + private Debugger.Interop.CorPub.ICorPublishProcess wrappedObject; + + internal Debugger.Interop.CorPub.ICorPublishProcess WrappedObject + { + get + { + return this.wrappedObject; + } + } + + public ICorPublishProcess(Debugger.Interop.CorPub.ICorPublishProcess wrappedObject) + { + this.wrappedObject = wrappedObject; + ResourceManager.TrackCOMObject(wrappedObject, typeof(ICorPublishProcess)); + } + + public static ICorPublishProcess Wrap(Debugger.Interop.CorPub.ICorPublishProcess objectToWrap) + { + if ((objectToWrap != null)) + { + return new ICorPublishProcess(objectToWrap); + } else + { + return null; + } + } + + public int ProcessId + { + get + { + uint id; + wrappedObject.GetProcessID(out id); + return (int)id; + } + } + + public bool IsManaged + { + get + { + int managed; + wrappedObject.IsManaged(out managed); + return managed != 0; + } + } + } +} + +#pragma warning restore 1591 diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 3109da9785..10f2f8f5b8 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -67,9 +67,9 @@ AsynchronousWaitDialog.cs - - - AttachToProcessForm.cs + + + AbstractAttachToProcessForm.cs @@ -715,9 +715,6 @@ - - AttachToProcessForm.cs - ExtractInterfaceDialog.cs diff --git a/src/Main/Base/Project/Src/Commands/DebugCommands.cs b/src/Main/Base/Project/Src/Commands/DebugCommands.cs index 4d1747e0d7..6f0aa2d3be 100644 --- a/src/Main/Base/Project/Src/Commands/DebugCommands.cs +++ b/src/Main/Base/Project/Src/Commands/DebugCommands.cs @@ -118,11 +118,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands { public override void Run() { - using (AttachToProcessForm attachForm = new AttachToProcessForm()) { - if (attachForm.ShowDialog() == DialogResult.OK) { - DebuggerService.CurrentDebugger.Attach(attachForm.Process); - } - } + DebuggerService.CurrentDebugger.ShowAttachDialog(); } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/AttachToProcessForm.Designer.cs b/src/Main/Base/Project/Src/Gui/Dialogs/AbstractAttachToProcessForm.Designer.cs similarity index 76% rename from src/Main/Base/Project/Src/Gui/Dialogs/AttachToProcessForm.Designer.cs rename to src/Main/Base/Project/Src/Gui/Dialogs/AbstractAttachToProcessForm.Designer.cs index 1cb0891352..6800386f66 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/AttachToProcessForm.Designer.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/AbstractAttachToProcessForm.Designer.cs @@ -1,13 +1,12 @@ // // -// -// +// // $Revision$ // namespace ICSharpCode.SharpDevelop.Gui { - partial class AttachToProcessForm + partial class AbstractAttachToProcessForm { /// /// Designer variable used to keep track of non-visual components. @@ -42,6 +41,8 @@ namespace ICSharpCode.SharpDevelop.Gui this.processColumnHeader = new System.Windows.Forms.ColumnHeader(); this.processIdColumnHeader = new System.Windows.Forms.ColumnHeader(); this.titleColumnHeader = new System.Windows.Forms.ColumnHeader(); + this.typeColumnHeader = new System.Windows.Forms.ColumnHeader(); + this.showNonManagedCheckBox = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // attachButton @@ -85,10 +86,12 @@ namespace ICSharpCode.SharpDevelop.Gui this.listView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.processColumnHeader, this.processIdColumnHeader, - this.titleColumnHeader}); + this.titleColumnHeader, + this.typeColumnHeader}); this.listView.FullRowSelect = true; this.listView.HideSelection = false; this.listView.Location = new System.Drawing.Point(0, 0); + this.listView.MultiSelect = false; this.listView.Name = "listView"; this.listView.Size = new System.Drawing.Size(636, 334); this.listView.Sorting = System.Windows.Forms.SortOrder.Ascending; @@ -96,6 +99,7 @@ namespace ICSharpCode.SharpDevelop.Gui this.listView.UseCompatibleStateImageBehavior = false; this.listView.View = System.Windows.Forms.View.Details; this.listView.ItemActivate += new System.EventHandler(this.ListViewItemActivate); + this.listView.SelectedIndexChanged += new System.EventHandler(this.ListViewSelectedIndexChanged); // // processColumnHeader // @@ -109,7 +113,24 @@ namespace ICSharpCode.SharpDevelop.Gui // titleColumnHeader // this.titleColumnHeader.Text = "Title"; - this.titleColumnHeader.Width = 337; + this.titleColumnHeader.Width = 294; + // + // typeColumnHeader + // + this.typeColumnHeader.Text = "Type"; + this.typeColumnHeader.Width = 74; + // + // showNonManagedCheckBox + // + this.showNonManagedCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.showNonManagedCheckBox.Location = new System.Drawing.Point(13, 339); + this.showNonManagedCheckBox.Name = "showNonManagedCheckBox"; + this.showNonManagedCheckBox.Size = new System.Drawing.Size(370, 24); + this.showNonManagedCheckBox.TabIndex = 5; + this.showNonManagedCheckBox.Text = "Show Non-Managed"; + this.showNonManagedCheckBox.UseVisualStyleBackColor = true; + this.showNonManagedCheckBox.CheckedChanged += new System.EventHandler(this.ShowNonManagedCheckBoxCheckedChanged); // // AttachToProcessForm // @@ -118,17 +139,20 @@ namespace ICSharpCode.SharpDevelop.Gui this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.cancelButton; this.ClientSize = new System.Drawing.Size(637, 374); + this.Controls.Add(this.showNonManagedCheckBox); this.Controls.Add(this.listView); this.Controls.Add(this.refreshButton); this.Controls.Add(this.cancelButton); this.Controls.Add(this.attachButton); - this.MinimumSize = new System.Drawing.Size(273, 140); - this.Name = "AttachToProcessForm"; + this.MinimumSize = new System.Drawing.Size(273, 240); + this.Name = "bstractAAttachToProcessForm"; this.ShowIcon = false; this.ShowInTaskbar = false; this.Text = "Attach to Process"; this.ResumeLayout(false); } + private System.Windows.Forms.CheckBox showNonManagedCheckBox; + private System.Windows.Forms.ColumnHeader typeColumnHeader; private System.Windows.Forms.ColumnHeader titleColumnHeader; private System.Windows.Forms.ColumnHeader processIdColumnHeader; private System.Windows.Forms.ColumnHeader processColumnHeader; diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/AttachToProcessForm.cs b/src/Main/Base/Project/Src/Gui/Dialogs/AbstractAttachToProcessForm.cs similarity index 72% rename from src/Main/Base/Project/Src/Gui/Dialogs/AttachToProcessForm.cs rename to src/Main/Base/Project/Src/Gui/Dialogs/AbstractAttachToProcessForm.cs index 664937c80e..e9b4b8e34d 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/AttachToProcessForm.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/AbstractAttachToProcessForm.cs @@ -7,18 +7,17 @@ using System; using System.Diagnostics; -using System.ComponentModel; using System.Drawing; -using System.IO; using System.Windows.Forms; using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Debugging; namespace ICSharpCode.SharpDevelop.Gui { - public partial class AttachToProcessForm : Form - { - public AttachToProcessForm() + public partial class AbstractAttachToProcessForm : Form + { + public AbstractAttachToProcessForm() { // // The InitializeComponent() call is required for Windows Forms designer support. @@ -32,29 +31,15 @@ namespace ICSharpCode.SharpDevelop.Gui public System.Diagnostics.Process Process { get { return GetSelectedProcess(); } } + + protected virtual void RefreshProcessList(ListView listView, bool showNonManaged) + { + } void RefreshProcessList() { - listView.Items.Clear(); - - Process currentProcess = Process.GetCurrentProcess(); - foreach (System.Diagnostics.Process process in System.Diagnostics.Process.GetProcesses()) { - try { - // Prevent attaching to our own process. - if (currentProcess.Id != process.Id) { - string fileName = Path.GetFileName(process.MainModule.FileName); - ListViewItem item = new ListViewItem(fileName); - item.SubItems.Add(process.Id.ToString()); - item.SubItems.Add(process.MainWindowTitle); - item.Tag = process; - listView.Items.Add(item); - } - } catch (Win32Exception) { - // Do nothing. - } - } + RefreshProcessList(listView, showNonManagedCheckBox.Checked); - listView.Sort(); if (listView.Items.Count > 0) { listView.Items[0].Selected = true; } else { @@ -95,5 +80,15 @@ namespace ICSharpCode.SharpDevelop.Gui Close(); } } + + void ShowNonManagedCheckBoxCheckedChanged(object sender, EventArgs e) + { + RefreshProcessList(); + } + + void ListViewSelectedIndexChanged(object sender, EventArgs e) + { + attachButton.Enabled = listView.SelectedItems.Count > 0; + } } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/AttachToProcessForm.resx b/src/Main/Base/Project/Src/Gui/Dialogs/AttachToProcessForm.resx deleted file mode 100644 index 7080a7d118..0000000000 --- a/src/Main/Base/Project/Src/Gui/Dialogs/AttachToProcessForm.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs b/src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs index 3d33f4304e..511e080bb5 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs @@ -53,6 +53,10 @@ namespace ICSharpCode.SharpDevelop.Debugging } } + public void ShowAttachDialog() + { + } + public void Attach(Process process) { } diff --git a/src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs b/src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs index 72b2f46772..1c8a99c7c8 100644 --- a/src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs +++ b/src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs @@ -55,11 +55,19 @@ namespace ICSharpCode.SharpDevelop.Debugging void StepOver(); void StepOut(); + + /// + /// Shows a dialog so the user can attach to a process. + /// + void ShowAttachDialog(); + /// + /// Used to attach to an existing process. + /// void Attach(Process process); void Detach(); - + /// /// Gets the current value of the variable as string that can be displayed in tooltips. /// diff --git a/src/Main/StartUp/Project/Resources/StringResources.resources b/src/Main/StartUp/Project/Resources/StringResources.resources index 0a1797f814..bb2180ed46 100644 Binary files a/src/Main/StartUp/Project/Resources/StringResources.resources and b/src/Main/StartUp/Project/Resources/StringResources.resources differ