Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(625)

Unified Diff: runtime/observatory/lib/src/elements/debugger.dart

Issue 920313003: Implement function entry breakpoints in Observatory debugger. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/observatory/lib/src/cli/command.dart ('k') | runtime/observatory/lib/src/service/object.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/observatory/lib/src/elements/debugger.dart
diff --git a/runtime/observatory/lib/src/elements/debugger.dart b/runtime/observatory/lib/src/elements/debugger.dart
index 52919aad147ca6bc6972d9dac7dae0e0d353e6dc..5aef04129e792da976443f461b124cfb52213672 100644
--- a/runtime/observatory/lib/src/elements/debugger.dart
+++ b/runtime/observatory/lib/src/elements/debugger.dart
@@ -232,48 +232,43 @@ class BreakCommand extends DebuggerCommand {
return SourceLocation.parse(debugger, arg).then((loc) {
if (loc.valid) {
if (loc.function != null) {
- debugger.console.print(
- 'Ignoring breakpoint at $loc: '
- 'Function entry breakpoints not yet implemented');
- return null;
- }
- if (loc.col != null) {
- // TODO(turnidge): Add tokenPos breakpoint support.
- debugger.console.print(
- 'Ignoring column: '
- 'adding breakpoint at a specific column not yet implemented');
- }
- return debugger.isolate.addBreakpoint(loc.script, loc.line).then((result) {
- if (result is DartError) {
- debugger.console.print('Unable to set breakpoint at ${loc}');
- } else {
- // TODO(turnidge): Adding a duplicate breakpoint is
- // currently ignored. May want to change the protocol to
- // inform us when this happens.
-
- // The BreakpointResolved event prints resolved
- // breakpoints already. Just print the unresolved ones here.
- Breakpoint bpt = result;
- if (!bpt.resolved) {
- var script = bpt.script;
- var bpId = bpt.number;
- var tokenPos = bpt.tokenPos;
- return script.load().then((_) {
- var line = script.tokenToLine(tokenPos);
- var col = script.tokenToCol(tokenPos);
- debugger.console.print(
- 'Future breakpoint ${bpId} added at '
- '${script.name}:${line}:${col}');
- });
- }
+ return debugger.isolate.addBreakpointAtEntry(loc.function)
+ .then((result) => _handleBreakpointResult(loc, result));
+ } else {
+ assert(loc.script != null);
+ if (loc.col != null) {
+ // TODO(turnidge): Add tokenPos breakpoint support.
+ debugger.console.print(
+ 'Ignoring column: '
+ 'adding breakpoint at a specific column not yet implemented');
}
- });
+ return debugger.isolate.addBreakpoint(loc.script, loc.line)
+ .then((result) => _handleBreakpointResult(loc, result));
+ }
} else {
debugger.console.print(loc.errorMessage);
}
});
}
+ Future _handleBreakpointResult(loc, result) {
+ if (result is DartError) {
+ debugger.console.print('Unable to set breakpoint at ${loc}');
+ } else {
+ // TODO(turnidge): Adding a duplicate breakpoint is
+ // currently ignored. May want to change the protocol to
+ // inform us when this happens.
+
+ // The BreakpointResolved event prints resolved
+ // breakpoints already. Just print the unresolved ones here.
+ Breakpoint bpt = result;
+ if (!bpt.resolved) {
+ return debugger._reportBreakpointAdded(bpt);
+ }
+ }
+ return new Future.value(null);
+ }
+
Future<List<String>> complete(List<String> args) {
if (args.length != 1) {
return new Future.value([]);
@@ -701,6 +696,26 @@ class ObservatoryDebugger extends Debugger {
}
}
+ Future _reportBreakpointAdded(Breakpoint bpt) {
+ var script = bpt.script;
+ return script.load().then((_) {
+ var bpId = bpt.number;
+ var tokenPos = bpt.tokenPos;
+ var line = script.tokenToLine(tokenPos);
+ var col = script.tokenToCol(tokenPos);
+ if (bpt.resolved) {
+ // TODO(turnidge): If this was a future breakpoint before, we
+ // should change the message to say that the breakpoint was 'resolved',
+ // rather than 'added'.
+ console.print(
+ 'Breakpoint ${bpId} added at ${script.name}:${line}:${col}');
+ } else {
+ console.print(
+ 'Future breakpoint ${bpId} added at ${script.name}:${line}:${col}');
+ }
+ });
+ }
+
void _onEvent(ServiceEvent event) {
if (event.owner != isolate) {
return;
@@ -724,13 +739,7 @@ class ObservatoryDebugger extends Debugger {
break;
case 'BreakpointResolved':
- var bpId = event.breakpoint.number;
- var script = event.breakpoint.script;
- var tokenPos = event.breakpoint.tokenPos;
- var line = script.tokenToLine(tokenPos);
- var col = script.tokenToCol(tokenPos);
- console.print(
- 'Breakpoint ${bpId} added at ${script.name}:${line}:${col}');
+ _reportBreakpointAdded(event.breakpoint);
break;
case '_Graph':
« no previous file with comments | « runtime/observatory/lib/src/cli/command.dart ('k') | runtime/observatory/lib/src/service/object.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698