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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/debugger.h ('k') | runtime/vm/debugger_api_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/debugger.h" 5 #include "vm/debugger.h"
6 6
7 #include "vm/code_index_table.h" 7 #include "vm/code_index_table.h"
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/flags.h" 10 #include "vm/flags.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 if (!cls.IsNull()) { 267 if (!cls.IsNull()) {
268 function = cls.LookupStaticFunction(function_name); 268 function = cls.LookupStaticFunction(function_name);
269 if (function.IsNull()) { 269 if (function.IsNull()) {
270 function = cls.LookupDynamicFunction(function_name); 270 function = cls.LookupDynamicFunction(function_name);
271 } 271 }
272 } 272 }
273 return function.raw(); 273 return function.raw();
274 } 274 }
275 275
276 276
277 Breakpoint* Debugger::SetBreakpointAtEntry(const Function& target_function) { 277 // TODO(hausner): Need to check whether a breakpoint for the
278 ASSERT(!target_function.IsNull()); 278 // location already exists and either return the existing breakpoint
279 // or return an error.
280 Breakpoint* Debugger::SetBreakpoint(const Function& target_function,
281 intptr_t token_index) {
282 if ((token_index < target_function.token_index()) ||
283 (target_function.end_token_index() <= token_index)) {
284 // The given token position is not within the target function.
285 return NULL;
286 }
279 if (!target_function.HasCode()) { 287 if (!target_function.HasCode()) {
280 Compiler::CompileFunction(target_function); 288 Compiler::CompileFunction(target_function);
281 } 289 }
282 Code& code = Code::Handle(target_function.code()); 290 Code& code = Code::Handle(target_function.code());
283 ASSERT(!code.IsNull()); 291 ASSERT(!code.IsNull());
284 PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors()); 292 PcDescriptors& desc = PcDescriptors::Handle(code.pc_descriptors());
285 for (int i = 0; i < desc.Length(); i++) { 293 for (int i = 0; i < desc.Length(); i++) {
294 if (desc.TokenIndex(i) < token_index) {
295 continue;
296 }
286 PcDescriptors::Kind kind = desc.DescriptorKind(i); 297 PcDescriptors::Kind kind = desc.DescriptorKind(i);
287 Breakpoint* bpt = NULL; 298 Breakpoint* bpt = NULL;
288 if (kind == PcDescriptors::kIcCall) { 299 if (kind == PcDescriptors::kIcCall) {
289 CodePatcher::PatchInstanceCallAt( 300 CodePatcher::PatchInstanceCallAt(
290 desc.PC(i), StubCode::BreakpointDynamicEntryPoint()); 301 desc.PC(i), StubCode::BreakpointDynamicEntryPoint());
291 bpt = new Breakpoint(target_function, i); 302 bpt = new Breakpoint(target_function, i);
292 } else if (kind == PcDescriptors::kOther) { 303 } else if (kind == PcDescriptors::kOther) {
293 if ((desc.TokenIndex(i) > 0) && CodePatcher::IsDartCall(desc.PC(i))) { 304 if ((desc.TokenIndex(i) > 0) && CodePatcher::IsDartCall(desc.PC(i))) {
294 CodePatcher::PatchStaticCallAt( 305 CodePatcher::PatchStaticCallAt(
295 desc.PC(i), StubCode::BreakpointStaticEntryPoint()); 306 desc.PC(i), StubCode::BreakpointStaticEntryPoint());
296 bpt = new Breakpoint(target_function, i); 307 bpt = new Breakpoint(target_function, i);
297 } 308 }
298 } 309 }
299 if (bpt != NULL) { 310 if (bpt != NULL) {
300 if (verbose) { 311 if (verbose) {
301 OS::Print("Setting breakpoint at '%s' line %d (PC %p)\n", 312 OS::Print("Setting breakpoint at '%s' line %d (PC %p)\n",
302 String::Handle(bpt->SourceUrl()).ToCString(), 313 String::Handle(bpt->SourceUrl()).ToCString(),
303 bpt->LineNumber(), 314 bpt->LineNumber(),
304 bpt->pc()); 315 bpt->pc());
305 } 316 }
306 AddBreakpoint(bpt); 317 AddBreakpoint(bpt);
307 return bpt; 318 return bpt;
308 } 319 }
309 } 320 }
310 return NULL; 321 return NULL;
311 } 322 }
312 323
313 324
325 Breakpoint* Debugger::SetBreakpointAtEntry(const Function& target_function) {
326 ASSERT(!target_function.IsNull());
327 return SetBreakpoint(target_function, target_function.token_index());
328 }
329
330
331 Breakpoint* Debugger::SetBreakpointAtLine(const String& script_url,
332 intptr_t line_number) {
333 Library& lib = Library::Handle();
334 Script& script = Script::Handle();
335 Isolate* isolate = Isolate::Current();
336 ASSERT(isolate != NULL);
337 lib = isolate->object_store()->registered_libraries();
338 while (!lib.IsNull()) {
339 script = lib.LookupScript(script_url);
340 if (!script.IsNull()) {
341 break;
342 }
343 lib = lib.next_registered();
344 }
345 if (script.IsNull()) {
346 return NULL;
347 }
348 intptr_t token_index_at_line = script.TokenIndexAtLine(line_number);
349 if (token_index_at_line < 0) {
350 // Script does not contain the given line number.
351 return NULL;
352 }
353 const Function& func =
354 Function::Handle(lib.LookupFunctionInScript(script, token_index_at_line));
355 if (func.IsNull()) {
356 return NULL;
357 }
358 return SetBreakpoint(func, token_index_at_line);
359 }
360
361
314 void Debugger::VisitObjectPointers(ObjectPointerVisitor* visitor) { 362 void Debugger::VisitObjectPointers(ObjectPointerVisitor* visitor) {
315 ASSERT(visitor != NULL); 363 ASSERT(visitor != NULL);
316 Breakpoint* bpt = this->breakpoints_; 364 Breakpoint* bpt = this->breakpoints_;
317 while (bpt != NULL) { 365 while (bpt != NULL) {
318 bpt->VisitObjectPointers(visitor); 366 bpt->VisitObjectPointers(visitor);
319 bpt = bpt->next(); 367 bpt = bpt->next();
320 } 368 }
321 } 369 }
322 370
323 371
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 446
399 447
400 void Debugger::AddBreakpoint(Breakpoint* bpt) { 448 void Debugger::AddBreakpoint(Breakpoint* bpt) {
401 ASSERT(bpt->next() == NULL); 449 ASSERT(bpt->next() == NULL);
402 bpt->set_next(this->breakpoints_); 450 bpt->set_next(this->breakpoints_);
403 this->breakpoints_ = bpt; 451 this->breakpoints_ = bpt;
404 } 452 }
405 453
406 454
407 } // namespace dart 455 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/debugger.h ('k') | runtime/vm/debugger_api_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698