|
|
|
@ -99,6 +99,8 @@ namespace ILSpy.Debugger.Services |
|
|
|
string errorProcessPaused = "Error.ProcessPaused"; |
|
|
|
string errorProcessPaused = "Error.ProcessPaused"; |
|
|
|
string errorCannotStepNoActiveFunction = "Threads.CannotStepNoActiveFunction"; |
|
|
|
string errorCannotStepNoActiveFunction = "Threads.CannotStepNoActiveFunction"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DecompiledLanguages Language { get; set; } |
|
|
|
|
|
|
|
|
|
|
|
public bool IsDebugging { |
|
|
|
public bool IsDebugging { |
|
|
|
get { |
|
|
|
get { |
|
|
|
return ServiceInitialized && debuggedProcess != null; |
|
|
|
return ServiceInitialized && debuggedProcess != null; |
|
|
|
@ -372,7 +374,8 @@ namespace ILSpy.Debugger.Services |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool CanEvaluate |
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
|
|
public bool CanEvaluate |
|
|
|
{ |
|
|
|
{ |
|
|
|
get { |
|
|
|
get { |
|
|
|
return debuggedProcess != null && !debuggedProcess.IsRunning && debuggedProcess.SelectedStackFrame != null; |
|
|
|
return debuggedProcess != null && !debuggedProcess.IsRunning && debuggedProcess.SelectedStackFrame != null; |
|
|
|
@ -385,7 +388,7 @@ namespace ILSpy.Debugger.Services |
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
public object GetTooltipControl(AstLocation logicalPosition, string variableName) |
|
|
|
public object GetTooltipControl(AstLocation logicalPosition, string variableName) |
|
|
|
{ |
|
|
|
{ |
|
|
|
return new DebuggerTooltipControl(logicalPosition, new ExpressionNode(ImageService.Breakpoint, variableName, null)); |
|
|
|
return new DebuggerTooltipControl(logicalPosition, new ExpressionNode(null, variableName, null)); |
|
|
|
//FIXME
|
|
|
|
//FIXME
|
|
|
|
// try {
|
|
|
|
// try {
|
|
|
|
// var tooltipExpression = GetExpression(variableName);
|
|
|
|
// var tooltipExpression = GetExpression(variableName);
|
|
|
|
@ -489,12 +492,28 @@ namespace ILSpy.Debugger.Services |
|
|
|
|
|
|
|
|
|
|
|
void AddBreakpoint(BreakpointBookmark bookmark) |
|
|
|
void AddBreakpoint(BreakpointBookmark bookmark) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint token; |
|
|
|
Breakpoint breakpoint = null; |
|
|
|
ILCodeMapping map = ILCodeMappings.GetInstructionByTypeAndLine(bookmark.TypeName, bookmark.LineNumber, out token); |
|
|
|
|
|
|
|
|
|
|
|
switch (Language) { |
|
|
|
|
|
|
|
case DecompiledLanguages.IL: |
|
|
|
|
|
|
|
uint token; |
|
|
|
|
|
|
|
ILCodeMapping map = ILCodeMappings.GetInstructionByTypeAndLine(bookmark.TypeName, bookmark.LineNumber, out token); |
|
|
|
|
|
|
|
|
|
|
|
if (map != null) { |
|
|
|
if (map != null) { |
|
|
|
Breakpoint breakpoint = new ILBreakpoint(debugger, bookmark.LineNumber, token, map.ILInstruction.Offset , bookmark.IsEnabled); |
|
|
|
breakpoint = new ILBreakpoint(debugger, bookmark.LineNumber, token, map.ILInstruction.Offset , bookmark.IsEnabled); |
|
|
|
debugger.Breakpoints.Add(breakpoint); |
|
|
|
debugger.Breakpoints.Add(breakpoint); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case DecompiledLanguages.CSharp: |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
throw new NotImplementedException("Not implemented!"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (breakpoint == null) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
// Action setBookmarkColor = delegate {
|
|
|
|
// Action setBookmarkColor = delegate {
|
|
|
|
// if (debugger.Processes.Count == 0) {
|
|
|
|
// if (debugger.Processes.Count == 0) {
|
|
|
|
@ -525,64 +544,63 @@ namespace ILSpy.Debugger.Services |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// };
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
|
|
// event handlers on bookmark and breakpoint don't need deregistration
|
|
|
|
// event handlers on bookmark and breakpoint don't need deregistration
|
|
|
|
bookmark.IsEnabledChanged += delegate { |
|
|
|
bookmark.IsEnabledChanged += delegate { |
|
|
|
breakpoint.Enabled = bookmark.IsEnabled; |
|
|
|
breakpoint.Enabled = bookmark.IsEnabled; |
|
|
|
}; |
|
|
|
}; |
|
|
|
breakpoint.Set += delegate { |
|
|
|
breakpoint.Set += delegate { |
|
|
|
//setBookmarkColor();
|
|
|
|
//setBookmarkColor();
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//setBookmarkColor();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EventHandler<CollectionItemEventArgs<Process>> bp_debugger_ProcessStarted = (sender, e) => { |
|
|
|
|
|
|
|
//setBookmarkColor();
|
|
|
|
|
|
|
|
// User can change line number by inserting or deleting lines
|
|
|
|
|
|
|
|
breakpoint.Line = bookmark.LineNumber; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
EventHandler<CollectionItemEventArgs<Process>> bp_debugger_ProcessExited = (sender, e) => { |
|
|
|
//setBookmarkColor();
|
|
|
|
//setBookmarkColor();
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EventHandler<BreakpointEventArgs> bp_debugger_BreakpointHit = |
|
|
|
|
|
|
|
new EventHandler<BreakpointEventArgs>( |
|
|
|
|
|
|
|
delegate(object sender, BreakpointEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//LoggingService.Debug(bookmark.Action + " " + bookmark.ScriptLanguage + " " + bookmark.Condition);
|
|
|
|
|
|
|
|
|
|
|
|
EventHandler<CollectionItemEventArgs<Process>> bp_debugger_ProcessStarted = (sender, e) => { |
|
|
|
switch (bookmark.Action) { |
|
|
|
//setBookmarkColor();
|
|
|
|
case BreakpointAction.Break: |
|
|
|
// User can change line number by inserting or deleting lines
|
|
|
|
break; |
|
|
|
breakpoint.Line = bookmark.LineNumber; |
|
|
|
case BreakpointAction.Condition: |
|
|
|
}; |
|
|
|
|
|
|
|
EventHandler<CollectionItemEventArgs<Process>> bp_debugger_ProcessExited = (sender, e) => { |
|
|
|
|
|
|
|
//setBookmarkColor();
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EventHandler<BreakpointEventArgs> bp_debugger_BreakpointHit = |
|
|
|
|
|
|
|
new EventHandler<BreakpointEventArgs>( |
|
|
|
|
|
|
|
delegate(object sender, BreakpointEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//LoggingService.Debug(bookmark.Action + " " + bookmark.ScriptLanguage + " " + bookmark.Condition);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (bookmark.Action) { |
|
|
|
|
|
|
|
case BreakpointAction.Break: |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case BreakpointAction.Condition: |
|
|
|
|
|
|
|
// if (Evaluate(bookmark.Condition, bookmark.ScriptLanguage))
|
|
|
|
// if (Evaluate(bookmark.Condition, bookmark.ScriptLanguage))
|
|
|
|
// DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAtBecause}") + "\n", bookmark.LineNumber, bookmark.FileName, bookmark.Condition));
|
|
|
|
// DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAtBecause}") + "\n", bookmark.LineNumber, bookmark.FileName, bookmark.Condition));
|
|
|
|
// else
|
|
|
|
// else
|
|
|
|
// this.debuggedProcess.AsyncContinue();
|
|
|
|
// this.debuggedProcess.AsyncContinue();
|
|
|
|
break; |
|
|
|
break; |
|
|
|
case BreakpointAction.Trace: |
|
|
|
case BreakpointAction.Trace: |
|
|
|
//DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAt}") + "\n", bookmark.LineNumber, bookmark.FileName));
|
|
|
|
//DebuggerService.PrintDebugMessage(string.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Conditional.Breakpoints.BreakpointHitAt}") + "\n", bookmark.LineNumber, bookmark.FileName));
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
BookmarkEventHandler bp_bookmarkManager_Removed = null; |
|
|
|
BookmarkEventHandler bp_bookmarkManager_Removed = null; |
|
|
|
bp_bookmarkManager_Removed = (sender, e) => { |
|
|
|
bp_bookmarkManager_Removed = (sender, e) => { |
|
|
|
if (bookmark == e.Bookmark) { |
|
|
|
if (bookmark == e.Bookmark) { |
|
|
|
debugger.Breakpoints.Remove(breakpoint); |
|
|
|
debugger.Breakpoints.Remove(breakpoint); |
|
|
|
|
|
|
|
|
|
|
|
// unregister the events
|
|
|
|
// unregister the events
|
|
|
|
debugger.Processes.Added -= bp_debugger_ProcessStarted; |
|
|
|
debugger.Processes.Added -= bp_debugger_ProcessStarted; |
|
|
|
debugger.Processes.Removed -= bp_debugger_ProcessExited; |
|
|
|
debugger.Processes.Removed -= bp_debugger_ProcessExited; |
|
|
|
breakpoint.Hit -= bp_debugger_BreakpointHit; |
|
|
|
breakpoint.Hit -= bp_debugger_BreakpointHit; |
|
|
|
BookmarkManager.Removed -= bp_bookmarkManager_Removed; |
|
|
|
BookmarkManager.Removed -= bp_bookmarkManager_Removed; |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
// register the events
|
|
|
|
// register the events
|
|
|
|
debugger.Processes.Added += bp_debugger_ProcessStarted; |
|
|
|
debugger.Processes.Added += bp_debugger_ProcessStarted; |
|
|
|
debugger.Processes.Removed += bp_debugger_ProcessExited; |
|
|
|
debugger.Processes.Removed += bp_debugger_ProcessExited; |
|
|
|
breakpoint.Hit += bp_debugger_BreakpointHit; |
|
|
|
breakpoint.Hit += bp_debugger_BreakpointHit; |
|
|
|
BookmarkManager.Removed += bp_bookmarkManager_Removed; |
|
|
|
BookmarkManager.Removed += bp_bookmarkManager_Removed; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool Evaluate(string code, string language) |
|
|
|
bool Evaluate(string code, string language) |
|
|
|
@ -723,13 +741,24 @@ namespace ILSpy.Debugger.Services |
|
|
|
DebuggerService.RemoveCurrentLineMarker(); |
|
|
|
DebuggerService.RemoveCurrentLineMarker(); |
|
|
|
|
|
|
|
|
|
|
|
if (debuggedProcess != null && debuggedProcess.SelectedStackFrame != null) { |
|
|
|
if (debuggedProcess != null && debuggedProcess.SelectedStackFrame != null) { |
|
|
|
uint token = (uint)debuggedProcess.SelectedStackFrame.MethodInfo.MetadataToken; |
|
|
|
switch (Language) { |
|
|
|
int ilOffset = debuggedProcess.SelectedStackFrame.IP; |
|
|
|
case DecompiledLanguages.IL: |
|
|
|
int line; |
|
|
|
// IL mapping
|
|
|
|
string typeName; |
|
|
|
uint token = (uint)debuggedProcess.SelectedStackFrame.MethodInfo.MetadataToken; |
|
|
|
ILCodeMappings.GetSourceCodeFromMetadataTokenAndOffset(token, ilOffset, out typeName, out line); |
|
|
|
int ilOffset = debuggedProcess.SelectedStackFrame.IP; |
|
|
|
if (typeName != null) { |
|
|
|
int line; |
|
|
|
DebuggerService.JumpToCurrentLine(typeName, line, 0, line, 0); |
|
|
|
string typeName; |
|
|
|
|
|
|
|
ILCodeMappings.GetSourceCodeFromMetadataTokenAndOffset(token, ilOffset, out typeName, out line); |
|
|
|
|
|
|
|
if (typeName != null) |
|
|
|
|
|
|
|
DebuggerService.JumpToCurrentLine(typeName, line, 0, line, 0); |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case DecompiledLanguages.CSharp: |
|
|
|
|
|
|
|
// FIXME CSharp mappings
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
throw new NotImplementedException("The language is not supported!"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|