| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "include/dart_debugger_api.h" | 5 #include "include/dart_debugger_api.h" |
| 6 | 6 |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 static Dart_PausedEventHandler* paused_event_handler = NULL; | 104 static Dart_PausedEventHandler* paused_event_handler = NULL; |
| 105 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL; | 105 static Dart_BreakpointResolvedHandler* bp_resolved_handler = NULL; |
| 106 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL; | 106 static Dart_ExceptionThrownHandler* exc_thrown_handler = NULL; |
| 107 static Dart_IsolateEventHandler* isolate_event_handler = NULL; | 107 static Dart_IsolateEventHandler* isolate_event_handler = NULL; |
| 108 | 108 |
| 109 | 109 |
| 110 static void DebuggerEventHandler(DebuggerEvent* event) { | 110 static void DebuggerEventHandler(DebuggerEvent* event) { |
| 111 Isolate* isolate = Isolate::Current(); | 111 Isolate* isolate = Isolate::Current(); |
| 112 ASSERT(isolate != NULL); | 112 ASSERT(isolate != NULL); |
| 113 ASSERT(isolate->debugger() != NULL); | |
| 114 Dart_EnterScope(); | 113 Dart_EnterScope(); |
| 115 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId(); | 114 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId(); |
| 116 if (event->type() == DebuggerEvent::kBreakpointReached) { | 115 if (event->type() == DebuggerEvent::kBreakpointReached) { |
| 117 if (paused_event_handler != NULL) { | 116 if (paused_event_handler != NULL) { |
| 118 Dart_CodeLocation location; | 117 Dart_CodeLocation location; |
| 119 ActivationFrame* top_frame = event->top_frame(); | 118 ActivationFrame* top_frame = event->top_frame(); |
| 120 location.script_url = Api::NewHandle(isolate, top_frame->SourceUrl()); | 119 location.script_url = Api::NewHandle(isolate, top_frame->SourceUrl()); |
| 121 const Library& lib = Library::Handle(top_frame->Library()); | 120 const Library& lib = Library::Handle(top_frame->Library()); |
| 122 location.library_id = lib.index(); | 121 location.library_id = lib.index(); |
| 123 location.token_pos = top_frame->TokenPos(); | 122 location.token_pos = top_frame->TokenPos(); |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 332 |
| 334 | 333 |
| 335 DART_EXPORT Dart_Handle Dart_SetBreakpoint( | 334 DART_EXPORT Dart_Handle Dart_SetBreakpoint( |
| 336 Dart_Handle script_url_in, | 335 Dart_Handle script_url_in, |
| 337 intptr_t line_number) { | 336 intptr_t line_number) { |
| 338 Isolate* isolate = Isolate::Current(); | 337 Isolate* isolate = Isolate::Current(); |
| 339 DARTSCOPE(isolate); | 338 DARTSCOPE(isolate); |
| 340 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 339 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
| 341 | 340 |
| 342 Debugger* debugger = isolate->debugger(); | 341 Debugger* debugger = isolate->debugger(); |
| 343 ASSERT(debugger != NULL); | |
| 344 Breakpoint* bpt = | 342 Breakpoint* bpt = |
| 345 debugger->SetBreakpointAtLine(script_url, line_number); | 343 debugger->SetBreakpointAtLine(script_url, line_number); |
| 346 if (bpt == NULL) { | 344 if (bpt == NULL) { |
| 347 return Api::NewError("%s: could not set breakpoint at line %" Pd " in '%s'", | 345 return Api::NewError("%s: could not set breakpoint at line %" Pd " in '%s'", |
| 348 CURRENT_FUNC, line_number, script_url.ToCString()); | 346 CURRENT_FUNC, line_number, script_url.ToCString()); |
| 349 } | 347 } |
| 350 return Dart_NewInteger(bpt->id()); | 348 return Dart_NewInteger(bpt->id()); |
| 351 } | 349 } |
| 352 | 350 |
| 353 | 351 |
| 354 DART_EXPORT Dart_Handle Dart_GetBreakpointURL(intptr_t bp_id) { | 352 DART_EXPORT Dart_Handle Dart_GetBreakpointURL(intptr_t bp_id) { |
| 355 Isolate* isolate = Isolate::Current(); | 353 Isolate* isolate = Isolate::Current(); |
| 356 DARTSCOPE(isolate); | 354 DARTSCOPE(isolate); |
| 357 Debugger* debugger = isolate->debugger(); | 355 Debugger* debugger = isolate->debugger(); |
| 358 ASSERT(debugger != NULL); | |
| 359 | 356 |
| 360 Breakpoint* bpt = debugger->GetBreakpointById(bp_id); | 357 Breakpoint* bpt = debugger->GetBreakpointById(bp_id); |
| 361 if (bpt == NULL) { | 358 if (bpt == NULL) { |
| 362 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", | 359 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", |
| 363 CURRENT_FUNC, bp_id); | 360 CURRENT_FUNC, bp_id); |
| 364 } | 361 } |
| 365 return Api::NewHandle(isolate, bpt->bpt_location()->url()); | 362 return Api::NewHandle(isolate, bpt->bpt_location()->url()); |
| 366 } | 363 } |
| 367 | 364 |
| 368 | 365 |
| 369 DART_EXPORT Dart_Handle Dart_GetBreakpointLine(intptr_t bp_id) { | 366 DART_EXPORT Dart_Handle Dart_GetBreakpointLine(intptr_t bp_id) { |
| 370 Isolate* isolate = Isolate::Current(); | 367 Isolate* isolate = Isolate::Current(); |
| 371 DARTSCOPE(isolate); | 368 DARTSCOPE(isolate); |
| 372 Debugger* debugger = isolate->debugger(); | 369 Debugger* debugger = isolate->debugger(); |
| 373 ASSERT(debugger != NULL); | |
| 374 | 370 |
| 375 Breakpoint* bpt = debugger->GetBreakpointById(bp_id); | 371 Breakpoint* bpt = debugger->GetBreakpointById(bp_id); |
| 376 if (bpt == NULL) { | 372 if (bpt == NULL) { |
| 377 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", | 373 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", |
| 378 CURRENT_FUNC, bp_id); | 374 CURRENT_FUNC, bp_id); |
| 379 } | 375 } |
| 380 return Dart_NewInteger(bpt->bpt_location()->LineNumber()); | 376 return Dart_NewInteger(bpt->bpt_location()->LineNumber()); |
| 381 } | 377 } |
| 382 | 378 |
| 383 | 379 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 if (!error.IsNull()) { | 452 if (!error.IsNull()) { |
| 457 return Api::NewHandle(isolate, error.raw()); | 453 return Api::NewHandle(isolate, error.raw()); |
| 458 } | 454 } |
| 459 return Api::Success(); | 455 return Api::Success(); |
| 460 } | 456 } |
| 461 | 457 |
| 462 | 458 |
| 463 DART_EXPORT Dart_Handle Dart_RemoveBreakpoint(intptr_t bp_id) { | 459 DART_EXPORT Dart_Handle Dart_RemoveBreakpoint(intptr_t bp_id) { |
| 464 Isolate* isolate = Isolate::Current(); | 460 Isolate* isolate = Isolate::Current(); |
| 465 DARTSCOPE(isolate); | 461 DARTSCOPE(isolate); |
| 466 Debugger* debugger = isolate->debugger(); | |
| 467 ASSERT(debugger != NULL); | |
| 468 | |
| 469 isolate->debugger()->RemoveBreakpoint(bp_id); | 462 isolate->debugger()->RemoveBreakpoint(bp_id); |
| 470 return Api::Success(); | 463 return Api::Success(); |
| 471 } | 464 } |
| 472 | 465 |
| 473 | 466 |
| 474 DART_EXPORT Dart_Handle Dart_SetStepOver() { | 467 DART_EXPORT Dart_Handle Dart_SetStepOver() { |
| 475 Isolate* isolate = Isolate::Current(); | 468 Isolate* isolate = Isolate::Current(); |
| 476 DARTSCOPE(isolate); | 469 DARTSCOPE(isolate); |
| 477 isolate->debugger()->SetStepOver(); | 470 isolate->debugger()->SetStepOver(); |
| 478 return Api::Success(); | 471 return Api::Success(); |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 return Api::CastIsolate(isolate); | 973 return Api::CastIsolate(isolate); |
| 981 } | 974 } |
| 982 | 975 |
| 983 | 976 |
| 984 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { | 977 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { |
| 985 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); | 978 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); |
| 986 return isolate->debugger()->GetIsolateId(); | 979 return isolate->debugger()->GetIsolateId(); |
| 987 } | 980 } |
| 988 | 981 |
| 989 } // namespace dart | 982 } // namespace dart |
| OLD | NEW |