Browse Source

Merge remote branch 'eusebiu/master'

pull/15/head
Eusebiu Marcu 15 years ago
parent
commit
8d447b5b69
  1. 23
      src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs
  2. 9
      src/AddIns/Debugger/Debugger.Core/Breakpoint.cs
  3. 66
      src/AddIns/Debugger/Debugger.Core/Process.cs
  4. 54
      src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
  5. 14
      src/Main/Base/Project/Src/Commands/DebugCommands.cs
  6. 5
      src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs
  7. 7
      src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs

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

@ -73,6 +73,12 @@ namespace ICSharpCode.SharpDevelop.Services
} }
} }
/// <inheritdoc/>
public bool BreakAtBegining {
get;
set;
}
protected virtual void OnProcessSelected(ProcessEventArgs e) protected virtual void OnProcessSelected(ProcessEventArgs e)
{ {
if (ProcessSelected != null) { if (ProcessSelected != null) {
@ -643,16 +649,21 @@ namespace ICSharpCode.SharpDevelop.Services
public void SelectProcess(Process process) public void SelectProcess(Process process)
{ {
if (debuggedProcess != null) { if (debuggedProcess != null) {
debuggedProcess.Paused -= debuggedProcess_DebuggingPaused; debuggedProcess.Paused -= debuggedProcess_DebuggingPaused;
debuggedProcess.ExceptionThrown -= debuggedProcess_ExceptionThrown; debuggedProcess.ExceptionThrown -= debuggedProcess_ExceptionThrown;
debuggedProcess.Resumed -= debuggedProcess_DebuggingResumed; debuggedProcess.Resumed -= debuggedProcess_DebuggingResumed;
} }
debuggedProcess = process; debuggedProcess = process;
if (debuggedProcess != null) { if (debuggedProcess != null) {
debuggedProcess.Paused += debuggedProcess_DebuggingPaused; debuggedProcess.Paused += debuggedProcess_DebuggingPaused;
debuggedProcess.ExceptionThrown += debuggedProcess_ExceptionThrown; debuggedProcess.ExceptionThrown += debuggedProcess_ExceptionThrown;
debuggedProcess.Resumed += debuggedProcess_DebuggingResumed; debuggedProcess.Resumed += debuggedProcess_DebuggingResumed;
debuggedProcess.BreakAtBegining = BreakAtBegining;
} }
// reset
BreakAtBegining = false;
JumpToCurrentLine(); JumpToCurrentLine();
OnProcessSelected(new ProcessEventArgs(process)); OnProcessSelected(new ProcessEventArgs(process));
} }

9
src/AddIns/Debugger/Debugger.Core/Breakpoint.cs

@ -88,6 +88,12 @@ namespace Debugger
} }
} }
public Breakpoint(NDebugger debugger, ICorDebugFunctionBreakpoint corBreakpoint)
{
this.debugger = debugger;
this.corBreakpoints.Add(corBreakpoint);
}
public Breakpoint(NDebugger debugger, string fileName, byte[] checkSum, int line, int column, bool enabled) public Breakpoint(NDebugger debugger, string fileName, byte[] checkSum, int line, int column, bool enabled)
{ {
this.debugger = debugger; this.debugger = debugger;
@ -134,6 +140,9 @@ namespace Debugger
internal bool SetBreakpoint(Module module) internal bool SetBreakpoint(Module module)
{ {
if (this.fileName == null)
return false;
SourcecodeSegment segment = SourcecodeSegment.Resolve(module, FileName, CheckSum, Line, Column); SourcecodeSegment segment = SourcecodeSegment.Resolve(module, FileName, CheckSum, Line, Column);
if (segment == null) return false; if (segment == null) return false;

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

@ -5,8 +5,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using Debugger.Interop;
using Debugger.Interop.CorDebug; using Debugger.Interop.CorDebug;
using Debugger.Interop.CorSym;
using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.Ast;
using ICSharpCode.NRefactory.Visitors; using ICSharpCode.NRefactory.Visitors;
@ -89,6 +89,11 @@ namespace Debugger
} }
} }
public bool BreakAtBegining {
get;
set;
}
public AppDomainCollection AppDomains { public AppDomainCollection AppDomains {
get { return appDomains; } get { return appDomains; }
} }
@ -113,6 +118,7 @@ namespace Debugger
activeEvals = new EvalCollection(debugger); activeEvals = new EvalCollection(debugger);
modules = new ModuleCollection(debugger); modules = new ModuleCollection(debugger);
modules.Added += OnModulesAdded;
threads = new ThreadCollection(debugger); threads = new ThreadCollection(debugger);
appDomains = new AppDomainCollection(debugger); appDomains = new AppDomainCollection(debugger);
} }
@ -138,21 +144,21 @@ namespace Debugger
fixed (uint* pprocessStartupInfo = processStartupInfo) fixed (uint* pprocessStartupInfo = processStartupInfo)
fixed (uint* pprocessInfo = processInfo) fixed (uint* pprocessInfo = processInfo)
outProcess = outProcess =
debugger.CorDebug.CreateProcess( debugger.CorDebug.CreateProcess(
filename, // lpApplicationName filename, // lpApplicationName
// If we do not prepend " ", the first argument migh just get lost // If we do not prepend " ", the first argument migh just get lost
" " + arguments, // lpCommandLine " " + arguments, // lpCommandLine
ref secAttr, // lpProcessAttributes ref secAttr, // lpProcessAttributes
ref secAttr, // lpThreadAttributes ref secAttr, // lpThreadAttributes
1,//TRUE // bInheritHandles 1,//TRUE // bInheritHandles
0x00000010 /*CREATE_NEW_CONSOLE*/, // dwCreationFlags 0x00000010 /*CREATE_NEW_CONSOLE*/, // dwCreationFlags
IntPtr.Zero, // lpEnvironment IntPtr.Zero, // lpEnvironment
workingDirectory, // lpCurrentDirectory workingDirectory, // lpCurrentDirectory
(uint)pprocessStartupInfo, // lpStartupInfo (uint)pprocessStartupInfo, // lpStartupInfo
(uint)pprocessInfo, // lpProcessInformation, (uint)pprocessInfo, // lpProcessInformation,
CorDebugCreateProcessFlags.DEBUG_NO_SPECIAL_OPTIONS // debuggingFlags CorDebugCreateProcessFlags.DEBUG_NO_SPECIAL_OPTIONS // debuggingFlags
); );
return new Process(debugger, outProcess, workingDirectory); return new Process(debugger, outProcess, workingDirectory);
} }
@ -266,7 +272,6 @@ namespace Debugger
} }
} }
#endregion #endregion
#region PauseSession & DebugeeState #region PauseSession & DebugeeState
@ -627,5 +632,32 @@ namespace Debugger
debugger.MTA2STA.PerformAllCalls(); debugger.MTA2STA.PerformAllCalls();
} }
} }
#region Break at begining
private void OnModulesAdded(object sender, CollectionItemEventArgs<Module> e)
{
if (BreakAtBegining) {
if (e.Item.SymReader == null) return; // No symbols
// create a BP at entry point
uint entryPoint = e.Item.SymReader.GetUserEntryPoint();
if (entryPoint == 0) return; // no EP
var mainFunction = e.Item.CorModule.GetFunctionFromToken(entryPoint);
var corBreakpoint = mainFunction.CreateBreakpoint();
corBreakpoint.Activate(1);
// create a SD BP
var breakpoint = new Breakpoint(this.debugger, corBreakpoint);
this.debugger.Breakpoints.Add(breakpoint);
breakpoint.Hit += delegate {
if (breakpoint != null)
breakpoint.Remove();
breakpoint = null;
};
BreakAtBegining = false;
}
}
#endregion
} }
} }

54
src/Main/Base/Project/ICSharpCode.SharpDevelop.addin

@ -928,9 +928,9 @@
</ComplexCondition> </ComplexCondition>
</Condition> </Condition>
<Condition name="IsProcessRunning" isdebugging = "True"> <Condition name="DebuggerSupports" debuggersupports = "Stepping">
<Condition name="DebuggerSupports" debuggersupports = "Stepping"> <Condition name = "SolutionOpen" action = "Disable">
<Condition name="IsProcessRunning" isprocessrunning = "False" action = "Disable"> <Condition name="DebuggerSupports" debuggersupports = "Start">
<ToolbarItem id = "SteppingSeparator" type = "Separator" /> <ToolbarItem id = "SteppingSeparator" type = "Separator" />
<ToolbarItem id = "Step over" <ToolbarItem id = "Step over"
icon = "Icons.16x16.Debug.StepOver" icon = "Icons.16x16.Debug.StepOver"
@ -940,10 +940,12 @@
icon = "Icons.16x16.Debug.StepInto" icon = "Icons.16x16.Debug.StepInto"
tooltip = "${res:XML.MainMenu.DebugMenu.StepInto.Description}" tooltip = "${res:XML.MainMenu.DebugMenu.StepInto.Description}"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepIntoDebuggingCommand"/> class = "ICSharpCode.SharpDevelop.Project.Commands.StepIntoDebuggingCommand"/>
<ToolbarItem id = "Step out" <Condition name="IsProcessRunning" isdebugging = "True">
icon = "Icons.16x16.Debug.StepOut" <ToolbarItem id = "Step out"
tooltip = "${res:XML.MainMenu.DebugMenu.StepOut.Description}" icon = "Icons.16x16.Debug.StepOut"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepOutDebuggingCommand"/> tooltip = "${res:XML.MainMenu.DebugMenu.StepOut.Description}"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepOutDebuggingCommand"/>
</Condition>
</Condition> </Condition>
</Condition> </Condition>
</Condition> </Condition>
@ -1548,23 +1550,27 @@
</Condition> </Condition>
<Condition name="DebuggerSupports" debuggersupports = "Stepping"> <Condition name="DebuggerSupports" debuggersupports = "Stepping">
<Condition name="IsProcessRunning" isprocessrunning = "False" isdebugging = "True" action = "Disable"> <Condition name = "SolutionOpen" action = "Disable">
<MenuItem id = "BeforeSteppingSeparator" type = "Separator" /> <Condition name="DebuggerSupports" debuggersupports = "Start">
<MenuItem id = "Step over" <MenuItem id = "BeforeSteppingSeparator" type = "Separator" />
label = "${res:XML.MainMenu.DebugMenu.StepOver}" <MenuItem id = "Step over"
icon = "Icons.16x16.Debug.StepOver" label = "${res:XML.MainMenu.DebugMenu.StepOver}"
shortcut = "F10" icon = "Icons.16x16.Debug.StepOver"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepDebuggingCommand"/> shortcut = "F10"
<MenuItem id = "Step into" class = "ICSharpCode.SharpDevelop.Project.Commands.StepDebuggingCommand"/>
label = "${res:XML.MainMenu.DebugMenu.StepInto}" <MenuItem id = "Step into"
icon = "Icons.16x16.Debug.StepInto" label = "${res:XML.MainMenu.DebugMenu.StepInto}"
shortcut = "F11" icon = "Icons.16x16.Debug.StepInto"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepIntoDebuggingCommand"/> shortcut = "F11"
<MenuItem id = "Step out" class = "ICSharpCode.SharpDevelop.Project.Commands.StepIntoDebuggingCommand"/>
label = "${res:XML.MainMenu.DebugMenu.StepOut}" <Condition name="IsProcessRunning" isdebugging = "True">
icon = "Icons.16x16.Debug.StepOut" <MenuItem id = "Step out"
shortcut = "Shift|F11" label = "${res:XML.MainMenu.DebugMenu.StepOut}"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepOutDebuggingCommand"/> icon = "Icons.16x16.Debug.StepOut"
shortcut = "Shift|F11"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepOutDebuggingCommand"/>
</Condition>
</Condition>
</Condition> </Condition>
</Condition> </Condition>

14
src/Main/Base/Project/Src/Commands/DebugCommands.cs

@ -83,7 +83,12 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
public override void Run() public override void Run()
{ {
LoggingService.Info("Debugger Command: StepOver"); LoggingService.Info("Debugger Command: StepOver");
DebuggerService.CurrentDebugger.StepOver(); if (!DebuggerService.CurrentDebugger.IsDebugging) {
DebuggerService.CurrentDebugger.BreakAtBegining = true;
new Execute().Run();
} else {
DebuggerService.CurrentDebugger.StepOver();
}
} }
} }
@ -92,7 +97,12 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
public override void Run() public override void Run()
{ {
LoggingService.Info("Debugger Command: StepInto"); LoggingService.Info("Debugger Command: StepInto");
DebuggerService.CurrentDebugger.StepInto(); if (!DebuggerService.CurrentDebugger.IsDebugging) {
DebuggerService.CurrentDebugger.BreakAtBegining = true;
new Execute().Run();
} else {
DebuggerService.CurrentDebugger.StepOver();
}
} }
} }

5
src/Main/Base/Project/Src/Services/Debugger/DefaultDebugger.cs

@ -25,6 +25,11 @@ namespace ICSharpCode.SharpDevelop.Debugging
} }
} }
/// <inheritdoc/>
public bool BreakAtBegining {
get; set;
}
public bool CanDebug(IProject project) public bool CanDebug(IProject project)
{ {
return true; return true;

7
src/Main/Base/Project/Src/Services/Debugger/IDebugger.cs

@ -25,6 +25,13 @@ namespace ICSharpCode.SharpDevelop.Debugging
get; get;
} }
/// <summary>
/// Gets or sets whether the debugger should break at the first line of execution.
/// </summary>
bool BreakAtBegining {
get; set;
}
bool CanDebug(IProject project); bool CanDebug(IProject project);
/// <summary> /// <summary>

Loading…
Cancel
Save