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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 location.token_pos = top_frame->TokenPos(); | 123 location.token_pos = top_frame->TokenPos(); |
124 intptr_t bp_id = 0; | 124 intptr_t bp_id = 0; |
125 if (event->breakpoint() != NULL) { | 125 if (event->breakpoint() != NULL) { |
126 ASSERT(event->breakpoint()->id() != ILLEGAL_BREAKPOINT_ID); | 126 ASSERT(event->breakpoint()->id() != ILLEGAL_BREAKPOINT_ID); |
127 bp_id = event->breakpoint()->id(); | 127 bp_id = event->breakpoint()->id(); |
128 } | 128 } |
129 (*paused_event_handler)(isolate_id, bp_id, location); | 129 (*paused_event_handler)(isolate_id, bp_id, location); |
130 } | 130 } |
131 } else if (event->type() == DebuggerEvent::kBreakpointResolved) { | 131 } else if (event->type() == DebuggerEvent::kBreakpointResolved) { |
132 if (bp_resolved_handler != NULL) { | 132 if (bp_resolved_handler != NULL) { |
133 Breakpoint* bpt = event->breakpoint(); | 133 SourceBreakpoint* bpt = event->breakpoint(); |
134 ASSERT(bpt != NULL); | 134 ASSERT(bpt != NULL); |
135 Dart_CodeLocation location; | 135 Dart_CodeLocation location; |
136 Library& library = Library::Handle(isolate); | 136 Library& library = Library::Handle(isolate); |
137 Script& script = Script::Handle(isolate); | 137 Script& script = Script::Handle(isolate); |
138 intptr_t token_pos; | 138 intptr_t token_pos; |
139 bpt->bpt_location()->GetCodeLocation(&library, &script, &token_pos); | 139 bpt->GetCodeLocation(&library, &script, &token_pos); |
140 location.script_url = Api::NewHandle(isolate, script.url()); | 140 location.script_url = Api::NewHandle(isolate, script.url()); |
141 location.library_id = library.index(); | 141 location.library_id = library.index(); |
142 location.token_pos = token_pos; | 142 location.token_pos = token_pos; |
143 (*bp_resolved_handler)(isolate_id, bpt->id(), location); | 143 (*bp_resolved_handler)(isolate_id, bpt->id(), location); |
144 } | 144 } |
145 } else if (event->type() == DebuggerEvent::kExceptionThrown) { | 145 } else if (event->type() == DebuggerEvent::kExceptionThrown) { |
146 if (exc_thrown_handler != NULL) { | 146 if (exc_thrown_handler != NULL) { |
147 Dart_Handle exception = | 147 Dart_Handle exception = |
148 Api::NewHandle(isolate, event->exception()->raw()); | 148 Api::NewHandle(isolate, event->exception()->raw()); |
149 Dart_StackTrace trace = | 149 Dart_StackTrace trace = |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 334 |
335 DART_EXPORT Dart_Handle Dart_SetBreakpoint( | 335 DART_EXPORT Dart_Handle Dart_SetBreakpoint( |
336 Dart_Handle script_url_in, | 336 Dart_Handle script_url_in, |
337 intptr_t line_number) { | 337 intptr_t line_number) { |
338 Isolate* isolate = Isolate::Current(); | 338 Isolate* isolate = Isolate::Current(); |
339 DARTSCOPE(isolate); | 339 DARTSCOPE(isolate); |
340 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 340 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
341 | 341 |
342 Debugger* debugger = isolate->debugger(); | 342 Debugger* debugger = isolate->debugger(); |
343 ASSERT(debugger != NULL); | 343 ASSERT(debugger != NULL); |
344 Breakpoint* bpt = | 344 SourceBreakpoint* bpt = |
345 debugger->SetBreakpointAtLine(script_url, line_number); | 345 debugger->SetBreakpointAtLine(script_url, line_number); |
346 if (bpt == NULL) { | 346 if (bpt == NULL) { |
347 return Api::NewError("%s: could not set breakpoint at line %" Pd " in '%s'", | 347 return Api::NewError("%s: could not set breakpoint at line %" Pd " in '%s'", |
348 CURRENT_FUNC, line_number, script_url.ToCString()); | 348 CURRENT_FUNC, line_number, script_url.ToCString()); |
349 } | 349 } |
350 return Dart_NewInteger(bpt->id()); | 350 return Dart_NewInteger(bpt->id()); |
351 } | 351 } |
352 | 352 |
353 | 353 |
354 DART_EXPORT Dart_Handle Dart_GetBreakpointURL(intptr_t bp_id) { | 354 DART_EXPORT Dart_Handle Dart_GetBreakpointURL(intptr_t bp_id) { |
355 Isolate* isolate = Isolate::Current(); | 355 Isolate* isolate = Isolate::Current(); |
356 DARTSCOPE(isolate); | 356 DARTSCOPE(isolate); |
357 Debugger* debugger = isolate->debugger(); | 357 Debugger* debugger = isolate->debugger(); |
358 ASSERT(debugger != NULL); | 358 ASSERT(debugger != NULL); |
359 | 359 |
360 Breakpoint* bpt = debugger->GetBreakpointById(bp_id); | 360 SourceBreakpoint* bpt = debugger->GetBreakpointById(bp_id); |
361 if (bpt == NULL) { | 361 if (bpt == NULL) { |
362 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", | 362 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", |
363 CURRENT_FUNC, bp_id); | 363 CURRENT_FUNC, bp_id); |
364 } | 364 } |
365 return Api::NewHandle(isolate, bpt->bpt_location()->url()); | 365 return Api::NewHandle(isolate, bpt->url()); |
366 } | 366 } |
367 | 367 |
368 | 368 |
369 DART_EXPORT Dart_Handle Dart_GetBreakpointLine(intptr_t bp_id) { | 369 DART_EXPORT Dart_Handle Dart_GetBreakpointLine(intptr_t bp_id) { |
370 Isolate* isolate = Isolate::Current(); | 370 Isolate* isolate = Isolate::Current(); |
371 DARTSCOPE(isolate); | 371 DARTSCOPE(isolate); |
372 Debugger* debugger = isolate->debugger(); | 372 Debugger* debugger = isolate->debugger(); |
373 ASSERT(debugger != NULL); | 373 ASSERT(debugger != NULL); |
374 | 374 |
375 Breakpoint* bpt = debugger->GetBreakpointById(bp_id); | 375 SourceBreakpoint* bpt = debugger->GetBreakpointById(bp_id); |
376 if (bpt == NULL) { | 376 if (bpt == NULL) { |
377 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", | 377 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", |
378 CURRENT_FUNC, bp_id); | 378 CURRENT_FUNC, bp_id); |
379 } | 379 } |
380 return Dart_NewInteger(bpt->bpt_location()->LineNumber()); | 380 return Dart_NewInteger(bpt->LineNumber()); |
381 } | 381 } |
382 | 382 |
383 | 383 |
384 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry( | 384 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry( |
385 Dart_Handle library_in, | 385 Dart_Handle library_in, |
386 Dart_Handle class_name_in, | 386 Dart_Handle class_name_in, |
387 Dart_Handle function_name_in) { | 387 Dart_Handle function_name_in) { |
388 Isolate* isolate = Isolate::Current(); | 388 Isolate* isolate = Isolate::Current(); |
389 DARTSCOPE(isolate); | 389 DARTSCOPE(isolate); |
390 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); | 390 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); |
(...skipping 13 matching lines...) Expand all Loading... |
404 debugger->ResolveFunction(library, class_name, function_name)); | 404 debugger->ResolveFunction(library, class_name, function_name)); |
405 if (bp_target.IsNull()) { | 405 if (bp_target.IsNull()) { |
406 const bool toplevel = class_name.Length() == 0; | 406 const bool toplevel = class_name.Length() == 0; |
407 return Api::NewError("%s: could not find function '%s%s%s'", | 407 return Api::NewError("%s: could not find function '%s%s%s'", |
408 CURRENT_FUNC, | 408 CURRENT_FUNC, |
409 toplevel ? "" : class_name.ToCString(), | 409 toplevel ? "" : class_name.ToCString(), |
410 toplevel ? "" : ".", | 410 toplevel ? "" : ".", |
411 function_name.ToCString()); | 411 function_name.ToCString()); |
412 } | 412 } |
413 | 413 |
414 Breakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target, false); | 414 SourceBreakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target); |
415 if (bpt == NULL) { | 415 if (bpt == NULL) { |
416 const char* target_name = Debugger::QualifiedFunctionName(bp_target); | 416 const char* target_name = Debugger::QualifiedFunctionName(bp_target); |
417 return Api::NewError("%s: no breakpoint location found in '%s'", | 417 return Api::NewError("%s: no breakpoint location found in '%s'", |
418 CURRENT_FUNC, target_name); | 418 CURRENT_FUNC, target_name); |
419 } | 419 } |
420 return Dart_NewInteger(bpt->id()); | 420 return Dart_NewInteger(bpt->id()); |
421 } | 421 } |
422 | 422 |
423 | 423 |
424 DART_EXPORT Dart_Handle Dart_OneTimeBreakAtEntry( | 424 DART_EXPORT Dart_Handle Dart_OneTimeBreakAtEntry( |
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 return Api::CastIsolate(isolate); | 980 return Api::CastIsolate(isolate); |
981 } | 981 } |
982 | 982 |
983 | 983 |
984 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { | 984 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { |
985 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); | 985 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); |
986 return isolate->debugger()->GetIsolateId(); | 986 return isolate->debugger()->GetIsolateId(); |
987 } | 987 } |
988 | 988 |
989 } // namespace dart | 989 } // namespace dart |
OLD | NEW |