1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using System.Diagnostics;
6
using ICSharpCode.NRefactory;
7
using ICSharpCode.SharpDevelop.Gui;
8
using ICSharpCode.SharpDevelop.Project;
10
namespace ICSharpCode.SharpDevelop.Debugging
12
public class DefaultDebugger : IDebugger
14
Process attachedProcess = null;
16
public bool IsDebugging {
18
return attachedProcess != null;
22
public bool IsProcessRunning {
29
public bool BreakAtBeginning {
33
public bool CanDebug(IProject project)
38
public void Start(ProcessStartInfo processStartInfo)
40
if (attachedProcess != null) {
44
OnDebugStarting(EventArgs.Empty);
46
attachedProcess = new Process();
47
attachedProcess.StartInfo = processStartInfo;
48
attachedProcess.Exited += new EventHandler(AttachedProcessExited);
49
attachedProcess.EnableRaisingEvents = true;
50
attachedProcess.Start();
51
OnDebugStarted(EventArgs.Empty);
53
OnDebugStopped(EventArgs.Empty);
54
throw new ApplicationException("Can't execute \"" + processStartInfo.FileName + "\"\n");
58
public void ShowAttachDialog()
62
public void Attach(Process process)
70
void AttachedProcessExited(object sender, EventArgs e)
72
attachedProcess.Exited -= new EventHandler(AttachedProcessExited);
73
attachedProcess.Dispose();
74
attachedProcess = null;
75
WorkbenchSingleton.SafeThreadAsyncCall(new Action<EventArgs>(OnDebugStopped),
79
public void StartWithoutDebugging(ProcessStartInfo processStartInfo)
81
Process.Start(processStartInfo);
86
if (attachedProcess != null) {
87
attachedProcess.Exited -= new EventHandler(AttachedProcessExited);
88
attachedProcess.Kill();
89
attachedProcess.Close();
90
attachedProcess.Dispose();
91
attachedProcess = null;
99
throw new NotSupportedException();
102
public void Continue()
104
throw new NotSupportedException();
108
public void StepInto()
110
throw new NotSupportedException();
113
public void StepOver()
115
throw new NotSupportedException();
118
public void StepOut()
120
throw new NotSupportedException();
124
/// Gets the current value of the variable as string that can be displayed in tooltips.
126
public string GetValueAsString(string variable)
132
/// Gets the tooltip control that shows the value of given variable.
133
/// Return null if no tooltip is available.
135
public object GetTooltipControl(Location logicalPosition, string variable)
140
public bool CanSetInstructionPointer(string filename, int line, int column)
145
public bool SetInstructionPointer(string filename, int line, int column)
151
public event EventHandler DebugStarted;
153
protected virtual void OnDebugStarted(EventArgs e)
155
if (DebugStarted != null) {
156
DebugStarted(this, e);
161
public event EventHandler IsProcessRunningChanged;
163
protected virtual void OnIsProcessRunningChanged(EventArgs e)
165
if (IsProcessRunningChanged != null) {
166
IsProcessRunningChanged(this, e);
171
public event EventHandler DebugStopped;
173
protected virtual void OnDebugStopped(EventArgs e)
175
if (DebugStopped != null) {
176
DebugStopped(this, e);
180
public event EventHandler DebugStarting;
182
protected virtual void OnDebugStarting(EventArgs e)
184
if (DebugStarting != null) {
185
DebugStarting(this, e);
189
public void Dispose()