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

Unified Diff: runtime/vm/debugger.cc

Issue 9240014: Set breakpoint at url, line number (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 11 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
Index: runtime/vm/debugger.cc
===================================================================
--- runtime/vm/debugger.cc (revision 3366)
+++ runtime/vm/debugger.cc (working copy)
@@ -274,8 +274,13 @@
}
-Breakpoint* Debugger::SetBreakpointAtEntry(const Function& target_function) {
- ASSERT(!target_function.IsNull());
+Breakpoint* Debugger::SetBreakpoint(const Function& target_function,
+ intptr_t token_index) {
+ if ((token_index < target_function.token_index()) ||
+ (target_function.end_token_index() <= token_index)) {
+ // The given token position is not within the target function.
+ return NULL;
+ }
siva 2012/01/18 01:32:03 Shouldn't we check in the breakpoint list that you
hausner 2012/01/18 23:26:38 Done
if (!target_function.HasCode()) {
Compiler::CompileFunction(target_function);
}
@@ -283,6 +288,9 @@
ASSERT(!code.IsNull());
PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors());
for (int i = 0; i < desc.Length(); i++) {
+ if (desc.TokenIndex(i) < token_index) {
+ continue;
+ }
siva 2012/01/18 01:32:03 If 'i' happens to be the last descriptor in this f
hausner 2012/01/18 23:26:38 We return NULL if there is no possible PC location
PcDescriptors::Kind kind = desc.DescriptorKind(i);
Breakpoint* bpt = NULL;
if (kind == PcDescriptors::kIcCall) {
@@ -292,25 +300,61 @@
} else if (kind == PcDescriptors::kOther) {
if ((desc.TokenIndex(i) > 0) && CodePatcher::IsDartCall(desc.PC(i))) {
CodePatcher::PatchStaticCallAt(
- desc.PC(i), StubCode::BreakpointStaticEntryPoint());
+ desc.PC(i), StubCode::BreakpointStaticEntryPoint());
bpt = new Breakpoint(target_function, i);
}
}
if (bpt != NULL) {
if (verbose) {
OS::Print("Setting breakpoint at '%s' line %d (PC %p)\n",
- String::Handle(bpt->SourceUrl()).ToCString(),
- bpt->LineNumber(),
- bpt->pc());
+ String::Handle(bpt->SourceUrl()).ToCString(),
+ bpt->LineNumber(),
+ bpt->pc());
}
AddBreakpoint(bpt);
return bpt;
}
}
siva 2012/01/18 01:32:03 why did you drop "return NULL"; ?
hausner 2012/01/18 23:26:38 Accident. I need automated test cases sooner than
- return NULL;
}
+Breakpoint* Debugger::SetBreakpointAtEntry(const Function& target_function) {
+ ASSERT(!target_function.IsNull());
+ return SetBreakpoint(target_function, target_function.token_index());
+}
+
+
+Breakpoint* Debugger::SetBreakpointAtLine(const String& script_url,
+ intptr_t line_number) {
+ Library& lib = Library::Handle();
+ Script& script = Script::Handle();
+ Isolate* isolate = Isolate::Current();
+ ASSERT(isolate != NULL);
+ lib = isolate->object_store()->registered_libraries();
+ while (!lib.IsNull()) {
+ script = lib.LookupScript(script_url);
+ if (!script.IsNull()) {
+ break;
+ }
+ lib = lib.next_registered();
+ }
+ if (script.IsNull()) {
+ return NULL;
+ }
+ intptr_t token_index_at_line = script.TokenIndexAtLine(line_number);
+ if (token_index_at_line < 0) {
+ // Script does not contain the given line number.
+ return NULL;
+ }
+ const Function& func =
+ Function::Handle(lib.LookupFunctionInScript(script, token_index_at_line));
+ if (func.IsNull()) {
+ return NULL;
+ }
+ return SetBreakpoint(func, token_index_at_line);
+}
+
+
void Debugger::VisitObjectPointers(ObjectPointerVisitor* visitor) {
ASSERT(visitor != NULL);
Breakpoint* bpt = this->breakpoints_;

Powered by Google App Engine
This is Rietveld 408576698