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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 } | 307 } |
308 return Api::Success(); | 308 return Api::Success(); |
309 } | 309 } |
310 | 310 |
311 | 311 |
312 DART_EXPORT Dart_Handle Dart_GetFunctionOrigin(Dart_Handle function_in) { | 312 DART_EXPORT Dart_Handle Dart_GetFunctionOrigin(Dart_Handle function_in) { |
313 Isolate* isolate = Isolate::Current(); | 313 Isolate* isolate = Isolate::Current(); |
314 DARTSCOPE(isolate); | 314 DARTSCOPE(isolate); |
315 UNWRAP_AND_CHECK_PARAM(Function, function, function_in); | 315 UNWRAP_AND_CHECK_PARAM(Function, function, function_in); |
316 | 316 |
317 Dart_Handle state = Api::CheckIsolateState(isolate); | |
318 if (::Dart_IsError(state)) { | |
319 return state; | |
320 } | |
321 | |
322 const Class& cls = Class::Handle(function.origin()); | 317 const Class& cls = Class::Handle(function.origin()); |
323 if (!cls.IsTopLevel()) { | 318 if (!cls.IsTopLevel()) { |
324 return Dart_NewInteger(cls.id()); | 319 return Dart_NewInteger(cls.id()); |
325 } | 320 } |
326 return Api::Null(); | 321 return Api::Null(); |
327 } | 322 } |
328 | 323 |
329 | 324 |
330 DART_EXPORT Dart_Handle Dart_GetLocalVariables( | 325 DART_EXPORT Dart_Handle Dart_GetLocalVariables( |
331 Dart_ActivationFrame activation_frame) { | 326 Dart_ActivationFrame activation_frame) { |
332 Isolate* isolate = Isolate::Current(); | 327 Isolate* isolate = Isolate::Current(); |
333 DARTSCOPE(isolate); | 328 DARTSCOPE(isolate); |
334 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 329 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
335 return Api::NewHandle(isolate, frame->GetLocalVariables()); | 330 return Api::NewHandle(isolate, frame->GetLocalVariables()); |
336 } | 331 } |
337 | 332 |
338 | 333 |
339 DART_EXPORT Dart_Handle Dart_SetBreakpoint( | 334 DART_EXPORT Dart_Handle Dart_SetBreakpoint( |
340 Dart_Handle script_url_in, | 335 Dart_Handle script_url_in, |
341 intptr_t line_number) { | 336 intptr_t line_number) { |
342 Isolate* isolate = Isolate::Current(); | 337 Isolate* isolate = Isolate::Current(); |
343 DARTSCOPE(isolate); | 338 DARTSCOPE(isolate); |
344 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 339 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
345 | 340 |
346 Dart_Handle state = Api::CheckIsolateState(isolate); | |
347 if (::Dart_IsError(state)) { | |
348 return state; | |
349 } | |
350 | |
351 Debugger* debugger = isolate->debugger(); | 341 Debugger* debugger = isolate->debugger(); |
352 ASSERT(debugger != NULL); | 342 ASSERT(debugger != NULL); |
353 SourceBreakpoint* bpt = | 343 SourceBreakpoint* bpt = |
354 debugger->SetBreakpointAtLine(script_url, line_number); | 344 debugger->SetBreakpointAtLine(script_url, line_number); |
355 if (bpt == NULL) { | 345 if (bpt == NULL) { |
356 return Api::NewError("%s: could not set breakpoint at line %" Pd " in '%s'", | 346 return Api::NewError("%s: could not set breakpoint at line %" Pd " in '%s'", |
357 CURRENT_FUNC, line_number, script_url.ToCString()); | 347 CURRENT_FUNC, line_number, script_url.ToCString()); |
358 } | 348 } |
359 return Dart_NewInteger(bpt->id()); | 349 return Dart_NewInteger(bpt->id()); |
360 } | 350 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry( | 383 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry( |
394 Dart_Handle library_in, | 384 Dart_Handle library_in, |
395 Dart_Handle class_name_in, | 385 Dart_Handle class_name_in, |
396 Dart_Handle function_name_in) { | 386 Dart_Handle function_name_in) { |
397 Isolate* isolate = Isolate::Current(); | 387 Isolate* isolate = Isolate::Current(); |
398 DARTSCOPE(isolate); | 388 DARTSCOPE(isolate); |
399 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); | 389 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); |
400 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in); | 390 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in); |
401 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in); | 391 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in); |
402 | 392 |
403 Dart_Handle state = Api::CheckIsolateState(isolate); | 393 // Ensure that the library is loaded. |
404 if (::Dart_IsError(state)) { | 394 if (!library.Loaded()) { |
405 return state; | 395 return Api::NewError( |
| 396 "%s expects library argument 'library_in' to be loaded.", |
| 397 CURRENT_FUNC); |
406 } | 398 } |
407 | 399 |
408 // Resolve the breakpoint target function. | 400 // Resolve the breakpoint target function. |
409 Debugger* debugger = isolate->debugger(); | 401 Debugger* debugger = isolate->debugger(); |
410 const Function& bp_target = Function::Handle( | 402 const Function& bp_target = Function::Handle( |
411 debugger->ResolveFunction(library, class_name, function_name)); | 403 debugger->ResolveFunction(library, class_name, function_name)); |
412 if (bp_target.IsNull()) { | 404 if (bp_target.IsNull()) { |
413 const bool toplevel = class_name.Length() == 0; | 405 const bool toplevel = class_name.Length() == 0; |
414 return Api::NewError("%s: could not find function '%s%s%s'", | 406 return Api::NewError("%s: could not find function '%s%s%s'", |
415 CURRENT_FUNC, | 407 CURRENT_FUNC, |
(...skipping 15 matching lines...) Expand all Loading... |
431 DART_EXPORT Dart_Handle Dart_OneTimeBreakAtEntry( | 423 DART_EXPORT Dart_Handle Dart_OneTimeBreakAtEntry( |
432 Dart_Handle library_in, | 424 Dart_Handle library_in, |
433 Dart_Handle class_name_in, | 425 Dart_Handle class_name_in, |
434 Dart_Handle function_name_in) { | 426 Dart_Handle function_name_in) { |
435 Isolate* isolate = Isolate::Current(); | 427 Isolate* isolate = Isolate::Current(); |
436 DARTSCOPE(isolate); | 428 DARTSCOPE(isolate); |
437 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); | 429 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); |
438 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in); | 430 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in); |
439 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in); | 431 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in); |
440 | 432 |
441 Dart_Handle state = Api::CheckIsolateState(isolate); | 433 // Ensure that the library is loaded. |
442 if (::Dart_IsError(state)) { | 434 if (!library.Loaded()) { |
443 return state; | 435 return Api::NewError( |
| 436 "%s expects library argument 'library_in' to be loaded.", |
| 437 CURRENT_FUNC); |
444 } | 438 } |
445 | 439 |
446 // Resolve the breakpoint target function. | 440 // Resolve the breakpoint target function. |
447 Debugger* debugger = isolate->debugger(); | 441 Debugger* debugger = isolate->debugger(); |
448 const Function& bp_target = Function::Handle( | 442 const Function& bp_target = Function::Handle( |
449 debugger->ResolveFunction(library, class_name, function_name)); | 443 debugger->ResolveFunction(library, class_name, function_name)); |
450 if (bp_target.IsNull()) { | 444 if (bp_target.IsNull()) { |
451 const bool toplevel = class_name.Length() == 0; | 445 const bool toplevel = class_name.Length() == 0; |
452 return Api::NewError("%s: could not find function '%s%s%s'", | 446 return Api::NewError("%s: could not find function '%s%s%s'", |
453 CURRENT_FUNC, | 447 CURRENT_FUNC, |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
981 return Api::CastIsolate(isolate); | 975 return Api::CastIsolate(isolate); |
982 } | 976 } |
983 | 977 |
984 | 978 |
985 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { | 979 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { |
986 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); | 980 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); |
987 return isolate->debugger()->GetIsolateId(); | 981 return isolate->debugger()->GetIsolateId(); |
988 } | 982 } |
989 | 983 |
990 } // namespace dart | 984 } // namespace dart |
OLD | NEW |