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

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

Issue 10407071: Introduce remote objects in Debugger protocol (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 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
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 25 matching lines...) Expand all
36 type* var = reinterpret_cast<type*>(param); 36 type* var = reinterpret_cast<type*>(param);
37 37
38 38
39 #define CHECK_NOT_NULL(param) \ 39 #define CHECK_NOT_NULL(param) \
40 if (param == NULL) { \ 40 if (param == NULL) { \
41 return Api::NewError("%s expects argument '%s' to be non-null.", \ 41 return Api::NewError("%s expects argument '%s' to be non-null.", \
42 CURRENT_FUNC, #param); \ 42 CURRENT_FUNC, #param); \
43 } 43 }
44 44
45 45
46 DART_EXPORT intptr_t Dart_CacheObject(Dart_Handle object_in) {
47 Isolate* isolate = Isolate::Current();
48 DARTSCOPE(isolate);
49 const Object& obj = Object::Handle(Api::UnwrapHandle(object_in));
50 if (obj.IsApiError()) {
51 return -1;
siva 2012/05/22 01:49:09 Since this is part of the API it might be better t
hausner 2012/05/22 18:03:57 I'd rather solve this by documenting that -1 is an
52 }
53 return isolate->debugger()->CacheObject(obj);
54 }
55
56
57 DART_EXPORT Dart_Handle Dart_GetCachedObject(intptr_t obj_id) {
58 Isolate* isolate = Isolate::Current();
59 DARTSCOPE(isolate);
60 if (!isolate->debugger()->IsValidObjectId(obj_id)) {
61 return Api::NewError("%s: object id %d is invalid", CURRENT_FUNC, obj_id);
62 }
63 return Api::NewHandle(isolate, isolate->debugger()->GetCachedObject(obj_id));
64 }
65
66
46 DART_EXPORT Dart_Handle Dart_StackTraceLength( 67 DART_EXPORT Dart_Handle Dart_StackTraceLength(
47 Dart_StackTrace trace, 68 Dart_StackTrace trace,
48 intptr_t* length) { 69 intptr_t* length) {
49 Isolate* isolate = Isolate::Current(); 70 Isolate* isolate = Isolate::Current();
50 DARTSCOPE(isolate); 71 DARTSCOPE(isolate);
51 CHECK_NOT_NULL(length); 72 CHECK_NOT_NULL(length);
52 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); 73 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace);
53 *length = stack_trace->Length(); 74 *length = stack_trace->Length();
54 return Api::True(isolate); 75 return Api::True(isolate);
55 } 76 }
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 378
358 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { 379 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) {
359 Isolate* isolate = Isolate::Current(); 380 Isolate* isolate = Isolate::Current();
360 DARTSCOPE(isolate); 381 DARTSCOPE(isolate);
361 Instance& obj = Instance::Handle(); 382 Instance& obj = Instance::Handle();
362 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); 383 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in);
363 return Api::NewHandle(isolate, obj.clazz()); 384 return Api::NewHandle(isolate, obj.clazz());
364 } 385 }
365 386
366 387
388 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object_in,
389 intptr_t* class_id) {
390 Isolate* isolate = Isolate::Current();
391 DARTSCOPE(isolate);
392 Instance& obj = Instance::Handle();
393 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in);
siva 2012/05/22 01:49:09 if (class_id == NULL) { return Api::NewError("
hausner 2012/05/22 18:03:57 It's kind of non-sensical to call this function wi
394 if (class_id != NULL) {
395 *class_id = Class::Handle(obj.clazz()).index();
396 }
397 return Api::True(isolate);
398 }
399
400
367 DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) { 401 DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) {
368 Isolate* isolate = Isolate::Current(); 402 Isolate* isolate = Isolate::Current();
369 DARTSCOPE(isolate); 403 DARTSCOPE(isolate);
370 Class& cls = Class::Handle(); 404 Class& cls = Class::Handle();
371 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); 405 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in);
372 return Api::NewHandle(isolate, cls.SuperClass()); 406 return Api::NewHandle(isolate, cls.SuperClass());
373 } 407 }
374 408
375 409
410 DART_EXPORT Dart_Handle Dart_GetClassInfo(
411 intptr_t cls_id,
412 Dart_Handle* class_name,
413 Dart_Handle* library,
414 intptr_t* super_class_id,
415 Dart_Handle* static_fields) {
416 Isolate* isolate = Isolate::Current();
417 DARTSCOPE(isolate);
418 if (!isolate->class_table()->IsValidIndex(cls_id)) {
419 return Api::NewError("%s: %d is not a valid class id",
420 CURRENT_FUNC, cls_id);
421 }
422 Class& cls = Class::Handle(isolate->class_table()->At(cls_id));
423 if (class_name != NULL) {
424 *class_name = Api::NewHandle(isolate, cls.Name());
425 }
426 if (library != NULL) {
427 *library = Api::NewHandle(isolate, cls.library());
428 }
429 if (super_class_id != NULL) {
430 *super_class_id = 0;
431 cls = cls.SuperClass();
432 if (!cls.IsNull()) {
433 *super_class_id = cls.index();
434 }
435 }
436 if (static_fields != NULL) {
437 *static_fields =
438 Api::NewHandle(isolate, isolate->debugger()->GetStaticFields(cls));
439 }
siva 2012/05/22 01:49:09 Ditto Api::NewError return values here for NULL po
hausner 2012/05/22 18:03:57 Not in this case. I want the caller to be able to
440 return Api::True(isolate);
441 }
442
443
376 DART_EXPORT Dart_Handle Dart_GetScriptSource( 444 DART_EXPORT Dart_Handle Dart_GetScriptSource(
377 Dart_Handle library_url_in, 445 Dart_Handle library_url_in,
378 Dart_Handle script_url_in) { 446 Dart_Handle script_url_in) {
379 Isolate* isolate = Isolate::Current(); 447 Isolate* isolate = Isolate::Current();
380 DARTSCOPE(isolate); 448 DARTSCOPE(isolate);
381 String& library_url = String::Handle(); 449 String& library_url = String::Handle();
382 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); 450 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in);
383 String& script_url = String::Handle(); 451 String& script_url = String::Handle();
384 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); 452 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in);
385 453
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 for (int i = 0; i < num_libs; i++) { 515 for (int i = 0; i < num_libs; i++) {
448 ASSERT(!lib.IsNull()); 516 ASSERT(!lib.IsNull());
449 lib_url = lib.url(); 517 lib_url = lib.url();
450 library_list.SetAt(i, lib_url); 518 library_list.SetAt(i, lib_url);
451 lib = lib.next_registered(); 519 lib = lib.next_registered();
452 } 520 }
453 return Api::NewHandle(isolate, library_list.raw()); 521 return Api::NewHandle(isolate, library_list.raw());
454 } 522 }
455 523
456 } // namespace dart 524 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698