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

Side by Side Diff: runtime/vm/debugger_api_impl.cc

Issue 14029016: Remove legacy debugger API function (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 8 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/lib/mirrors.cc ('k') | runtime/vm/debugger_api_impl_test.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) 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/dart_api_impl.h" 7 #include "vm/dart_api_impl.h"
8 #include "vm/dart_api_state.h" 8 #include "vm/dart_api_state.h"
9 #include "vm/debugger.h" 9 #include "vm/debugger.h"
10 #include "vm/isolate.h" 10 #include "vm/isolate.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 SourceBreakpoint* bpt = 266 SourceBreakpoint* bpt =
267 debugger->SetBreakpointAtLine(script_url, line_number); 267 debugger->SetBreakpointAtLine(script_url, line_number);
268 if (bpt == NULL) { 268 if (bpt == NULL) {
269 return Api::NewError("%s: could not set breakpoint at line %"Pd" in '%s'", 269 return Api::NewError("%s: could not set breakpoint at line %"Pd" in '%s'",
270 CURRENT_FUNC, line_number, script_url.ToCString()); 270 CURRENT_FUNC, line_number, script_url.ToCString());
271 } 271 }
272 return Dart_NewInteger(bpt->id()); 272 return Dart_NewInteger(bpt->id());
273 } 273 }
274 274
275 275
276 // TODO(hausner): remove this function.
277 DART_EXPORT Dart_Handle Dart_SetBreakpointAtLine(
278 Dart_Handle script_url_in,
279 Dart_Handle line_number_in,
280 Dart_Breakpoint* breakpoint) {
281 Isolate* isolate = Isolate::Current();
282 DARTSCOPE(isolate);
283 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in);
284 UNWRAP_AND_CHECK_PARAM(Integer, line_number, line_number_in);
285 CHECK_NOT_NULL(breakpoint);
286
287 if (!line_number.IsSmi()) {
288 return Api::NewError("%s: line number out of range", CURRENT_FUNC);
289 }
290 intptr_t line = line_number.AsInt64Value();
291
292 Dart_Handle state = Api::CheckIsolateState(isolate);
293 if (::Dart_IsError(state)) {
294 return state;
295 }
296
297 Dart_Handle result = Api::True(isolate);
298 *breakpoint = NULL;
299 Debugger* debugger = isolate->debugger();
300 ASSERT(debugger != NULL);
301 SourceBreakpoint* bpt =
302 debugger->SetBreakpointAtLine(script_url, line);
303 if (bpt == NULL) {
304 result = Api::NewError("%s: could not set breakpoint at line %"Pd" of '%s'",
305 CURRENT_FUNC, line, script_url.ToCString());
306 } else {
307 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt);
308 }
309 return result;
310 }
311
312
313 DART_EXPORT Dart_Handle Dart_GetBreakpointURL(intptr_t bp_id) { 276 DART_EXPORT Dart_Handle Dart_GetBreakpointURL(intptr_t bp_id) {
314 Isolate* isolate = Isolate::Current(); 277 Isolate* isolate = Isolate::Current();
315 DARTSCOPE(isolate); 278 DARTSCOPE(isolate);
316 Debugger* debugger = isolate->debugger(); 279 Debugger* debugger = isolate->debugger();
317 ASSERT(debugger != NULL); 280 ASSERT(debugger != NULL);
318 281
319 SourceBreakpoint* bpt = debugger->GetBreakpointById(bp_id); 282 SourceBreakpoint* bpt = debugger->GetBreakpointById(bp_id);
320 if (bpt == NULL) { 283 if (bpt == NULL) {
321 return Api::NewError("%s: breakpoint with id %"Pd" does not exist", 284 return Api::NewError("%s: breakpoint with id %"Pd" does not exist",
322 CURRENT_FUNC, bp_id); 285 CURRENT_FUNC, bp_id);
(...skipping 13 matching lines...) Expand all
336 return Api::NewError("%s: breakpoint with id %"Pd" does not exist", 299 return Api::NewError("%s: breakpoint with id %"Pd" does not exist",
337 CURRENT_FUNC, bp_id); 300 CURRENT_FUNC, bp_id);
338 } 301 }
339 return Dart_NewInteger(bpt->LineNumber()); 302 return Dart_NewInteger(bpt->LineNumber());
340 } 303 }
341 304
342 305
343 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry( 306 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry(
344 Dart_Handle library_in, 307 Dart_Handle library_in,
345 Dart_Handle class_name_in, 308 Dart_Handle class_name_in,
346 Dart_Handle function_name_in, 309 Dart_Handle function_name_in) {
347 Dart_Breakpoint* breakpoint) {
348 Isolate* isolate = Isolate::Current(); 310 Isolate* isolate = Isolate::Current();
349 DARTSCOPE(isolate); 311 DARTSCOPE(isolate);
350 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); 312 UNWRAP_AND_CHECK_PARAM(Library, library, library_in);
351 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in); 313 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in);
352 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in); 314 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in);
353 CHECK_NOT_NULL(breakpoint);
354 315
355 Dart_Handle state = Api::CheckIsolateState(isolate); 316 Dart_Handle state = Api::CheckIsolateState(isolate);
356 if (::Dart_IsError(state)) { 317 if (::Dart_IsError(state)) {
357 return state; 318 return state;
358 } 319 }
359 320
360 // Resolve the breakpoint target function. 321 // Resolve the breakpoint target function.
361 Debugger* debugger = isolate->debugger(); 322 Debugger* debugger = isolate->debugger();
362 const Function& bp_target = Function::Handle( 323 const Function& bp_target = Function::Handle(
363 debugger->ResolveFunction(library, class_name, function_name)); 324 debugger->ResolveFunction(library, class_name, function_name));
364 if (bp_target.IsNull()) { 325 if (bp_target.IsNull()) {
365 const bool toplevel = class_name.Length() == 0; 326 const bool toplevel = class_name.Length() == 0;
366 return Api::NewError("%s: could not find function '%s%s%s'", 327 return Api::NewError("%s: could not find function '%s%s%s'",
367 CURRENT_FUNC, 328 CURRENT_FUNC,
368 toplevel ? "" : class_name.ToCString(), 329 toplevel ? "" : class_name.ToCString(),
369 toplevel ? "" : ".", 330 toplevel ? "" : ".",
370 function_name.ToCString()); 331 function_name.ToCString());
371 } 332 }
372 333
373 Dart_Handle result = Api::True(isolate);
374 *breakpoint = NULL;
375
376 SourceBreakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target); 334 SourceBreakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target);
377 if (bpt == NULL) { 335 if (bpt == NULL) {
378 const char* target_name = Debugger::QualifiedFunctionName(bp_target); 336 const char* target_name = Debugger::QualifiedFunctionName(bp_target);
379 result = Api::NewError("%s: no breakpoint location found in '%s'", 337 return Api::NewError("%s: no breakpoint location found in '%s'",
380 CURRENT_FUNC, target_name); 338 CURRENT_FUNC, target_name);
381 } else {
382 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt);
383 } 339 }
384 return result; 340 return Dart_NewInteger(bpt->id());
385 } 341 }
386 342
387 343
388 DART_EXPORT Dart_Handle Dart_OneTimeBreakAtEntry( 344 DART_EXPORT Dart_Handle Dart_OneTimeBreakAtEntry(
389 Dart_Handle library_in, 345 Dart_Handle library_in,
390 Dart_Handle class_name_in, 346 Dart_Handle class_name_in,
391 Dart_Handle function_name_in) { 347 Dart_Handle function_name_in) {
392 Isolate* isolate = Isolate::Current(); 348 Isolate* isolate = Isolate::Current();
393 DARTSCOPE(isolate); 349 DARTSCOPE(isolate);
394 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); 350 UNWRAP_AND_CHECK_PARAM(Library, library, library_in);
(...skipping 16 matching lines...) Expand all
411 toplevel ? "" : class_name.ToCString(), 367 toplevel ? "" : class_name.ToCString(),
412 toplevel ? "" : ".", 368 toplevel ? "" : ".",
413 function_name.ToCString()); 369 function_name.ToCString());
414 } 370 }
415 371
416 debugger->OneTimeBreakAtEntry(bp_target); 372 debugger->OneTimeBreakAtEntry(bp_target);
417 return Api::True(isolate); 373 return Api::True(isolate);
418 } 374 }
419 375
420 376
421
422
423
424 DART_EXPORT Dart_Handle Dart_RemoveBreakpoint(intptr_t bp_id) { 377 DART_EXPORT Dart_Handle Dart_RemoveBreakpoint(intptr_t bp_id) {
425 Isolate* isolate = Isolate::Current(); 378 Isolate* isolate = Isolate::Current();
426 DARTSCOPE(isolate); 379 DARTSCOPE(isolate);
427 Debugger* debugger = isolate->debugger(); 380 Debugger* debugger = isolate->debugger();
428 ASSERT(debugger != NULL); 381 ASSERT(debugger != NULL);
429 382
430 isolate->debugger()->RemoveBreakpoint(bp_id); 383 isolate->debugger()->RemoveBreakpoint(bp_id);
431 return Api::True(isolate); 384 return Api::True(isolate);
432 } 385 }
433 386
434 387
435 DART_EXPORT Dart_Handle Dart_DeleteBreakpoint(
436 Dart_Breakpoint breakpoint_in) {
437 Isolate* isolate = Isolate::Current();
438 DARTSCOPE(isolate);
439
440 CHECK_AND_CAST(SourceBreakpoint, breakpoint, breakpoint_in);
441 isolate->debugger()->RemoveBreakpoint(breakpoint->id());
442 return Api::True(isolate);
443 }
444
445
446 DART_EXPORT Dart_Handle Dart_SetStepOver() { 388 DART_EXPORT Dart_Handle Dart_SetStepOver() {
447 Isolate* isolate = Isolate::Current(); 389 Isolate* isolate = Isolate::Current();
448 DARTSCOPE(isolate); 390 DARTSCOPE(isolate);
449 isolate->debugger()->SetStepOver(); 391 isolate->debugger()->SetStepOver();
450 return Api::True(isolate); 392 return Api::True(isolate);
451 } 393 }
452 394
453 395
454 DART_EXPORT Dart_Handle Dart_SetStepInto() { 396 DART_EXPORT Dart_Handle Dart_SetStepInto() {
455 Isolate* isolate = Isolate::Current(); 397 Isolate* isolate = Isolate::Current();
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 DARTSCOPE(isolate); 701 DARTSCOPE(isolate);
760 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); 702 const Library& lib = Library::Handle(Library::GetLibrary(library_id));
761 if (lib.IsNull()) { 703 if (lib.IsNull()) {
762 return Api::NewError("%s: %"Pd" is not a valid library id", 704 return Api::NewError("%s: %"Pd" is not a valid library id",
763 CURRENT_FUNC, library_id); 705 CURRENT_FUNC, library_id);
764 } 706 }
765 return Api::NewHandle(isolate, lib.url()); 707 return Api::NewHandle(isolate, lib.url());
766 } 708 }
767 709
768 710
769 DART_EXPORT Dart_Handle Dart_GetLibraryURLs() {
770 Isolate* isolate = Isolate::Current();
771 ASSERT(isolate != NULL);
772 DARTSCOPE(isolate);
773
774 const GrowableObjectArray& libs =
775 GrowableObjectArray::Handle(isolate->object_store()->libraries());
776 int num_libs = libs.Length();
777
778 // Create new list and populate with the url of loaded libraries.
779 Library &lib = Library::Handle();
780 String& lib_url = String::Handle();
781 const Array& library_url_list = Array::Handle(Array::New(num_libs));
782 for (int i = 0; i < num_libs; i++) {
783 lib ^= libs.At(i);
784 ASSERT(!lib.IsNull());
785 lib_url = lib.url();
786 library_url_list.SetAt(i, lib_url);
787 }
788 return Api::NewHandle(isolate, library_url_list.raw());
789 }
790
791
792 DART_EXPORT Dart_Handle Dart_GetLibraryDebuggable(intptr_t library_id, 711 DART_EXPORT Dart_Handle Dart_GetLibraryDebuggable(intptr_t library_id,
793 bool* is_debuggable) { 712 bool* is_debuggable) {
794 Isolate* isolate = Isolate::Current(); 713 Isolate* isolate = Isolate::Current();
795 ASSERT(isolate != NULL); 714 ASSERT(isolate != NULL);
796 DARTSCOPE(isolate); 715 DARTSCOPE(isolate);
797 CHECK_NOT_NULL(is_debuggable); 716 CHECK_NOT_NULL(is_debuggable);
798 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); 717 const Library& lib = Library::Handle(Library::GetLibrary(library_id));
799 if (lib.IsNull()) { 718 if (lib.IsNull()) {
800 return Api::NewError("%s: %"Pd" is not a valid library id", 719 return Api::NewError("%s: %"Pd" is not a valid library id",
801 CURRENT_FUNC, library_id); 720 CURRENT_FUNC, library_id);
(...skipping 25 matching lines...) Expand all
827 746
828 747
829 DART_EXPORT char* Dart_GetVmStatus(const char* request) { 748 DART_EXPORT char* Dart_GetVmStatus(const char* request) {
830 if (strncmp(request, "/isolate/", 9) == 0) { 749 if (strncmp(request, "/isolate/", 9) == 0) {
831 return Isolate::GetStatus(request); 750 return Isolate::GetStatus(request);
832 } 751 }
833 return NULL; 752 return NULL;
834 } 753 }
835 754
836 } // namespace dart 755 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/debugger_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698