Browse Source

Merge remote branch 'eusebiu/master'

pull/15/head
Eusebiu Marcu 15 years ago
parent
commit
8d447b5b69
  1. 11
      src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs
  2. 9
      src/AddIns/Debugger/Debugger.Core/Breakpoint.cs
  3. 36
      src/AddIns/Debugger/Debugger.Core/Process.cs
  4. 12
      src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
  5. 12
      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

11
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) {
@ -652,7 +658,12 @@ namespace ICSharpCode.SharpDevelop.Services
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;

36
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);
} }
@ -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
} }
} }

12
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="IsProcessRunning" isprocessrunning = "False" action = "Disable"> <Condition name = "SolutionOpen" 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,6 +940,7 @@
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"/>
<Condition name="IsProcessRunning" isdebugging = "True">
<ToolbarItem id = "Step out" <ToolbarItem id = "Step out"
icon = "Icons.16x16.Debug.StepOut" icon = "Icons.16x16.Debug.StepOut"
tooltip = "${res:XML.MainMenu.DebugMenu.StepOut.Description}" tooltip = "${res:XML.MainMenu.DebugMenu.StepOut.Description}"
@ -947,6 +948,7 @@
</Condition> </Condition>
</Condition> </Condition>
</Condition> </Condition>
</Condition>
<ToolbarItem id = "ChooseConfigurationSeparator" type = "Separator"/> <ToolbarItem id = "ChooseConfigurationSeparator" type = "Separator"/>
@ -1548,7 +1550,8 @@
</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">
<Condition name="DebuggerSupports" debuggersupports = "Start">
<MenuItem id = "BeforeSteppingSeparator" type = "Separator" /> <MenuItem id = "BeforeSteppingSeparator" type = "Separator" />
<MenuItem id = "Step over" <MenuItem id = "Step over"
label = "${res:XML.MainMenu.DebugMenu.StepOver}" label = "${res:XML.MainMenu.DebugMenu.StepOver}"
@ -1560,6 +1563,7 @@
icon = "Icons.16x16.Debug.StepInto" icon = "Icons.16x16.Debug.StepInto"
shortcut = "F11" shortcut = "F11"
class = "ICSharpCode.SharpDevelop.Project.Commands.StepIntoDebuggingCommand"/> class = "ICSharpCode.SharpDevelop.Project.Commands.StepIntoDebuggingCommand"/>
<Condition name="IsProcessRunning" isdebugging = "True">
<MenuItem id = "Step out" <MenuItem id = "Step out"
label = "${res:XML.MainMenu.DebugMenu.StepOut}" label = "${res:XML.MainMenu.DebugMenu.StepOut}"
icon = "Icons.16x16.Debug.StepOut" icon = "Icons.16x16.Debug.StepOut"
@ -1567,6 +1571,8 @@
class = "ICSharpCode.SharpDevelop.Project.Commands.StepOutDebuggingCommand"/> class = "ICSharpCode.SharpDevelop.Project.Commands.StepOutDebuggingCommand"/>
</Condition> </Condition>
</Condition> </Condition>
</Condition>
</Condition>
<MenuItem id = "ToggleBreakpointSeparator" type = "Separator" /> <MenuItem id = "ToggleBreakpointSeparator" type = "Separator" />
<ComplexCondition action="Disable"> <ComplexCondition action="Disable">

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

@ -83,16 +83,26 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
public override void Run() public override void Run()
{ {
LoggingService.Info("Debugger Command: StepOver"); LoggingService.Info("Debugger Command: StepOver");
if (!DebuggerService.CurrentDebugger.IsDebugging) {
DebuggerService.CurrentDebugger.BreakAtBegining = true;
new Execute().Run();
} else {
DebuggerService.CurrentDebugger.StepOver(); DebuggerService.CurrentDebugger.StepOver();
} }
} }
}
public class StepIntoDebuggingCommand : AbstractMenuCommand public class StepIntoDebuggingCommand : AbstractMenuCommand
{ {
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