Browse Source

fix evaluation in console pad; refactoring;

pull/16/head
Eusebiu Marcu 15 years ago
parent
commit
4c83b381c9
  1. 9
      src/AddIns/Debugger/Debugger.AddIn/Pads/ConsolePad.cs
  2. 16
      src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs
  3. 6
      src/AddIns/Debugger/Debugger.Core/StackFrame.cs
  4. 3
      src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs

9
src/AddIns/Debugger/Debugger.AddIn/Pads/ConsolePad.cs

@ -52,7 +52,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
return "The process is running"; return "The process is running";
} }
try { try {
Value val = ExpressionEvaluator.Evaluate(code, SelectedLanguage, process.SelectedStackFrame); Value val = ExpressionEvaluator.Evaluate(code, SelectedLanguage, process.SelectedThread.MostRecentStackFrame);
return ExpressionEvaluator.FormatValue(val); return ExpressionEvaluator.FormatValue(val);
} catch (GetValueException e) { } catch (GetValueException e) {
return e.Message; return e.Message;
@ -107,7 +107,7 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
if (this.process == null || this.process.IsRunning) if (this.process == null || this.process.IsRunning)
return; return;
if (this.process.SelectedStackFrame == null || this.process.SelectedStackFrame.NextStatement == null) if (this.process.SelectedThread.MostRecentStackFrame == null || this.process.SelectedThread.MostRecentStackFrame.NextStatement == null)
return; return;
foreach (char ch in e.Text) { foreach (char ch in e.Text) {
@ -119,7 +119,10 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
void ShowDotCompletion(string currentText) void ShowDotCompletion(string currentText)
{ {
var seg = process.SelectedStackFrame.NextStatement; if (this.process.SelectedThread.MostRecentStackFrame == null || this.process.SelectedThread.MostRecentStackFrame.NextStatement == null)
return;
var seg = process.SelectedThread.MostRecentStackFrame.NextStatement;
var expressionFinder = ParserService.GetExpressionFinder(seg.Filename); var expressionFinder = ParserService.GetExpressionFinder(seg.Filename);
var info = ParserService.GetParseInformation(seg.Filename); var info = ParserService.GetParseInformation(seg.Filename);

16
src/AddIns/Debugger/Debugger.AddIn/Pads/WatchPad.cs

@ -170,25 +170,25 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads
Utils.DoEvents(debuggedProcess); Utils.DoEvents(debuggedProcess);
List<TreeNode> nodes = new List<TreeNode>(); List<TreeNode> nodes = new List<TreeNode>();
foreach (var nod in watchList.WatchItems) { foreach (var node in watchList.WatchItems) {
try { try {
LoggingService.Info("Evaluating: " + (string.IsNullOrEmpty(nod.Name) ? "is null or empty!" : nod.Name)); LoggingService.Info("Evaluating: " + (string.IsNullOrEmpty(node.Name) ? "is null or empty!" : node.Name));
var nodExpression = debugger.GetExpression(nod.Name); var nodExpression = debugger.GetExpression(node.Name);
//Value val = ExpressionEvaluator.Evaluate(nod.Name, nod.Language, debuggedProcess.SelectedStackFrame); //Value val = ExpressionEvaluator.Evaluate(nod.Name, nod.Language, debuggedProcess.SelectedStackFrame);
ExpressionNode valNode = new ExpressionNode(null, nod.Name, nodExpression); ExpressionNode valNode = new ExpressionNode(null, node.Name, nodExpression);
nodes.Add(valNode); nodes.Add(valNode);
} }
catch (GetValueException) { catch (GetValueException) {
string error = String.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.InvalidExpression}"), nod.Name); string error = String.Format(StringParser.Parse("${res:MainWindow.Windows.Debug.Watch.InvalidExpression}"), node.Name);
ErrorInfoNode infoNode = new ErrorInfoNode(nod.Name, error); ErrorInfoNode infoNode = new ErrorInfoNode(node.Name, error);
nodes.Add(infoNode); nodes.Add(infoNode);
} }
} }
// rebuild list // rebuild list
watchList.WatchItems.Clear(); watchList.WatchItems.Clear();
foreach (var nod in nodes) foreach (var node in nodes)
watchList.WatchItems.Add(nod); watchList.WatchItems.Add(node);
} }
catch(AbortedBecauseDebuggeeResumedException) { } catch(AbortedBecauseDebuggeeResumedException) { }
catch(Exception ex) { catch(Exception ex) {

6
src/AddIns/Debugger/Debugger.Core/StackFrame.cs

@ -63,7 +63,7 @@ namespace Debugger
/// (That is has accesss to the .pdb file) </summary> /// (That is has accesss to the .pdb file) </summary>
public bool HasSymbols { public bool HasSymbols {
get { get {
return GetSegmentForOffet(0) != null; return GetSegmentForOffset(0) != null;
} }
} }
@ -143,7 +143,7 @@ namespace Debugger
public int SourceCodeLine { get; set; } public int SourceCodeLine { get; set; }
SourcecodeSegment GetSegmentForOffet(int offset) SourcecodeSegment GetSegmentForOffset(int offset)
{ {
if (SourceCodeLine != 0) if (SourceCodeLine != 0)
return SourcecodeSegment.ResolveForIL(this.MethodInfo.DebugModule, corFunction, SourceCodeLine, offset, ILRanges); return SourcecodeSegment.ResolveForIL(this.MethodInfo.DebugModule, corFunction, SourceCodeLine, offset, ILRanges);
@ -241,7 +241,7 @@ namespace Debugger
/// </summary> /// </summary>
public SourcecodeSegment NextStatement { public SourcecodeSegment NextStatement {
get { get {
return GetSegmentForOffet(IP); return GetSegmentForOffset(IP);
} }
} }

3
src/Main/Base/Project/Src/Services/Debugger/CurrentLineBookmark.cs

@ -27,6 +27,9 @@ namespace ICSharpCode.SharpDevelop.Debugging
if (tecp != null) { if (tecp != null) {
SetPosition(tecp.TextEditor.FileName, tecp.TextEditor.Document, makerStartLine, makerStartColumn, makerEndLine, makerEndColumn); SetPosition(tecp.TextEditor.FileName, tecp.TextEditor.Document, makerStartLine, makerStartColumn, makerEndLine, makerEndColumn);
} else { } else {
if (makerStartLine == 0)
return;
dynamic codeView = viewContent.Control; dynamic codeView = viewContent.Control;
SetPosition(null, codeView.TextEditor.Document as IDocument, makerStartLine, makerStartColumn, makerEndLine, makerEndColumn); SetPosition(null, codeView.TextEditor.Document as IDocument, makerStartLine, makerStartColumn, makerEndLine, makerEndColumn);
codeView.IconBarManager.Bookmarks.Add(CurrentLineBookmark.instance); codeView.IconBarManager.Bookmarks.Add(CurrentLineBookmark.instance);

Loading…
Cancel
Save