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

Side by Side Diff: runtime/bin/dbg_connection.cc

Issue 10698039: Support for lists in debugger wire protocol (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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/bin/dbg_connection.h ('k') | tools/ddbg.dart » ('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 "bin/dbg_connection.h" 5 #include "bin/dbg_connection.h"
6 #include "bin/dartutils.h" 6 #include "bin/dartutils.h"
7 #include "bin/socket.h" 7 #include "bin/socket.h"
8 #include "bin/thread.h" 8 #include "bin/thread.h"
9 #include "bin/utils.h" 9 #include "bin/utils.h"
10 10
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 class MessageBuffer { 48 class MessageBuffer {
49 public: 49 public:
50 explicit MessageBuffer(int fd); 50 explicit MessageBuffer(int fd);
51 ~MessageBuffer(); 51 ~MessageBuffer();
52 void ReadData(); 52 void ReadData();
53 bool IsValidMessage() const; 53 bool IsValidMessage() const;
54 void PopMessage(); 54 void PopMessage();
55 int MessageId() const; 55 int MessageId() const;
56 const char* Params() const; 56 const char* Params() const;
57 intptr_t GetIntParam(const char* name) const; 57 intptr_t GetIntParam(const char* name) const;
58 intptr_t GetOptIntParam(const char* name, intptr_t default_val) const;
58 // GetStringParam mallocs the buffer that it returns. Caller must free. 59 // GetStringParam mallocs the buffer that it returns. Caller must free.
59 char* GetStringParam(const char* name) const; 60 char* GetStringParam(const char* name) const;
60 char* buf() const { return buf_; } 61 char* buf() const { return buf_; }
61 bool Alive() const { return connection_is_alive_; } 62 bool Alive() const { return connection_is_alive_; }
62 63
63 private: 64 private:
64 static const int kInitialBufferSize = 256; 65 static const int kInitialBufferSize = 256;
65 char* buf_; 66 char* buf_;
66 int buf_length_; 67 int buf_length_;
67 int fd_; 68 int fd_;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 129
129 intptr_t MessageBuffer::GetIntParam(const char* name) const { 130 intptr_t MessageBuffer::GetIntParam(const char* name) const {
130 const char* params = Params(); 131 const char* params = Params();
131 ASSERT(params != NULL); 132 ASSERT(params != NULL);
132 dart::JSONReader r(params); 133 dart::JSONReader r(params);
133 r.Seek(name); 134 r.Seek(name);
134 ASSERT(r.Type() == dart::JSONReader::kInteger); 135 ASSERT(r.Type() == dart::JSONReader::kInteger);
135 return strtol(r.ValueChars(), NULL, 10); 136 return strtol(r.ValueChars(), NULL, 10);
136 } 137 }
137 138
139
140 intptr_t MessageBuffer::GetOptIntParam(const char* name,
141 intptr_t default_val) const {
142 const char* params = Params();
143 ASSERT(params != NULL);
144 dart::JSONReader r(params);
145 r.Seek(name);
146 if (r.Type() == dart::JSONReader::kInteger) {
147 return strtol(r.ValueChars(), NULL, 10);
148 } else {
149 return default_val;
150 }
151 }
152
153
138 char* MessageBuffer::GetStringParam(const char* name) const { 154 char* MessageBuffer::GetStringParam(const char* name) const {
139 const char* params = Params(); 155 const char* params = Params();
140 ASSERT(params != NULL); 156 ASSERT(params != NULL);
141 dart::JSONReader pr(params); 157 dart::JSONReader pr(params);
142 pr.Seek(name); 158 pr.Seek(name);
143 if (pr.Type() != dart::JSONReader::kString) { 159 if (pr.Type() != dart::JSONReader::kString) {
144 return NULL; 160 return NULL;
145 } 161 }
146 intptr_t buflen = pr.ValueLen() + 1; 162 intptr_t buflen = pr.ValueLen() + 1;
147 char* param_chars = reinterpret_cast<char*>(malloc(buflen)); 163 char* param_chars = reinterpret_cast<char*>(malloc(buflen));
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 ASSERT(Dart_IsString(lib_url)); 418 ASSERT(Dart_IsString(lib_url));
403 msg.Printf("%s{\"id\":%d,\"url\":", (i == 0) ? "" : ", ", lib_id); 419 msg.Printf("%s{\"id\":%d,\"url\":", (i == 0) ? "" : ", ", lib_id);
404 FormatEncodedString(&msg, lib_url); 420 FormatEncodedString(&msg, lib_url);
405 msg.Printf("}"); 421 msg.Printf("}");
406 } 422 }
407 msg.Printf("]}}"); 423 msg.Printf("]}}");
408 SendMsg(&msg); 424 SendMsg(&msg);
409 } 425 }
410 426
411 427
412 static void FormatRemoteObj(dart::TextBuffer* buf, Dart_Handle object) { 428 static void FormatTextualValue(dart::TextBuffer* buf, Dart_Handle object) {
413 intptr_t obj_id = Dart_CacheObject(object);
414 ASSERT(obj_id >= 0);
415 buf->Printf("{\"objectId\":%d,", obj_id);
416 const char* kind = "object";
417 if (Dart_IsInteger(object)) {
418 kind = "integer";
419 } else if (Dart_IsString(object)) {
420 kind = "string";
421 } else if (Dart_IsBoolean(object)) {
422 kind = "boolean";
423 }
424 buf->Printf("\"kind\":\"%s\",", kind);
425 buf->Printf("\"text\":");
426 Dart_Handle text; 429 Dart_Handle text;
427 if (Dart_IsNull(object)) { 430 if (Dart_IsNull(object)) {
428 text = Dart_Null(); 431 text = Dart_Null();
429 } else { 432 } else {
430 text = Dart_ToString(object); 433 text = Dart_ToString(object);
431 } 434 }
435 buf->Printf("\"text\":");
432 if (Dart_IsNull(text)) { 436 if (Dart_IsNull(text)) {
433 buf->Printf("null"); 437 buf->Printf("null");
434 } else if (Dart_IsError(text)) { 438 } else if (Dart_IsError(text)) {
435 FormatErrorMsg(buf, text); 439 FormatErrorMsg(buf, text);
436 } else { 440 } else {
437 FormatEncodedString(buf, text); 441 FormatEncodedString(buf, text);
438 } 442 }
443 }
444
445
446 static void FormatValue(dart::TextBuffer* buf, Dart_Handle object) {
447 if (Dart_IsInteger(object)) {
448 buf->Printf("\"kind\":\"integer\",");
449 } else if (Dart_IsString(object)) {
450 buf->Printf("\"kind\":\"string\",");
451 } else if (Dart_IsBoolean(object)) {
452 buf->Printf("\"kind\":\"boolean\",");
453 } else if (Dart_IsList(object)) {
454 intptr_t len = 0;
455 Dart_Handle res = Dart_ListLength(object, &len);
456 ASSERT_NOT_ERROR(res);
457 buf->Printf("\"kind\":\"list\",\"length\":%d,", len);
458 } else {
459 buf->Printf("\"kind\":\"object\",");
460 }
461 FormatTextualValue(buf, object);
462 }
463
464
465 static void FormatValueObj(dart::TextBuffer* buf, Dart_Handle object) {
466 buf->Printf("{");
467 FormatValue(buf, object);
439 buf->Printf("}"); 468 buf->Printf("}");
440 } 469 }
441 470
442 471
443 static void FormatField(dart::TextBuffer* buf, 472 static void FormatRemoteObj(dart::TextBuffer* buf, Dart_Handle object) {
444 Dart_Handle object_name, 473 intptr_t obj_id = Dart_CacheObject(object);
445 Dart_Handle object) { 474 ASSERT(obj_id >= 0);
475 buf->Printf("{\"objectId\":%d,", obj_id);
476 FormatValue(buf, object);
477 buf->Printf("}");
478 }
479
480
481 static void FormatNamedValue(dart::TextBuffer* buf,
482 Dart_Handle object_name,
483 Dart_Handle object) {
446 ASSERT(Dart_IsString(object_name)); 484 ASSERT(Dart_IsString(object_name));
447 buf->Printf("{\"name\":\"%s\",", GetStringChars(object_name)); 485 buf->Printf("{\"name\":\"%s\",", GetStringChars(object_name));
448 buf->Printf("\"value\":"); 486 buf->Printf("\"value\":");
449 FormatRemoteObj(buf, object); 487 FormatRemoteObj(buf, object);
450 buf->Printf("}"); 488 buf->Printf("}");
451 } 489 }
452 490
453 491
454 static void FormatFieldList(dart::TextBuffer* buf, 492 static void FormatNamedValueList(dart::TextBuffer* buf,
455 Dart_Handle obj_list) { 493 Dart_Handle obj_list) {
456 ASSERT(Dart_IsList(obj_list)); 494 ASSERT(Dart_IsList(obj_list));
457 intptr_t list_length = 0; 495 intptr_t list_length = 0;
458 Dart_Handle res = Dart_ListLength(obj_list, &list_length); 496 Dart_Handle res = Dart_ListLength(obj_list, &list_length);
459 ASSERT_NOT_ERROR(res); 497 ASSERT_NOT_ERROR(res);
460 ASSERT(list_length % 2 == 0); 498 ASSERT(list_length % 2 == 0);
461 buf->Printf("["); 499 buf->Printf("[");
462 for (int i = 0; i + 1 < list_length; i += 2) { 500 for (int i = 0; i + 1 < list_length; i += 2) {
463 Dart_Handle name_handle = Dart_ListGetAt(obj_list, i); 501 Dart_Handle name_handle = Dart_ListGetAt(obj_list, i);
464 ASSERT_NOT_ERROR(name_handle); 502 ASSERT_NOT_ERROR(name_handle);
465 Dart_Handle value_handle = Dart_ListGetAt(obj_list, i + 1); 503 Dart_Handle value_handle = Dart_ListGetAt(obj_list, i + 1);
466 ASSERT_NOT_ERROR(value_handle); 504 ASSERT_NOT_ERROR(value_handle);
467 if (i > 0) { 505 if (i > 0) {
468 buf->Printf(","); 506 buf->Printf(",");
469 } 507 }
470 FormatField(buf, name_handle, value_handle); 508 FormatNamedValue(buf, name_handle, value_handle);
471 } 509 }
472 buf->Printf("]"); 510 buf->Printf("]");
473 } 511 }
474 512
475 513
476 static const char* FormatClassProps(dart::TextBuffer* buf, 514 static const char* FormatClassProps(dart::TextBuffer* buf,
477 intptr_t cls_id) { 515 intptr_t cls_id) {
478 Dart_Handle name, static_fields; 516 Dart_Handle name, static_fields;
479 intptr_t super_id = -1; 517 intptr_t super_id = -1;
480 intptr_t library_id = -1; 518 intptr_t library_id = -1;
481 Dart_Handle res = 519 Dart_Handle res =
482 Dart_GetClassInfo(cls_id, &name, &library_id, &super_id, &static_fields); 520 Dart_GetClassInfo(cls_id, &name, &library_id, &super_id, &static_fields);
483 RETURN_IF_ERROR(res); 521 RETURN_IF_ERROR(res);
484 RETURN_IF_ERROR(name); 522 RETURN_IF_ERROR(name);
485 buf->Printf("{\"name\":\"%s\",", GetStringChars(name)); 523 buf->Printf("{\"name\":\"%s\",", GetStringChars(name));
486 if (super_id > 0) { 524 if (super_id > 0) {
487 buf->Printf("\"superclassId\":%d,", super_id); 525 buf->Printf("\"superclassId\":%d,", super_id);
488 } 526 }
489 buf->Printf("\"libraryId\":%d,", library_id); 527 buf->Printf("\"libraryId\":%d,", library_id);
490 RETURN_IF_ERROR(static_fields); 528 RETURN_IF_ERROR(static_fields);
491 buf->Printf("\"fields\":"); 529 buf->Printf("\"fields\":");
492 FormatFieldList(buf, static_fields); 530 FormatNamedValueList(buf, static_fields);
493 buf->Printf("}"); 531 buf->Printf("}");
494 return NULL; 532 return NULL;
495 } 533 }
496 534
497 535
498 static const char* FormatLibraryProps(dart::TextBuffer* buf, 536 static const char* FormatLibraryProps(dart::TextBuffer* buf,
499 intptr_t lib_id) { 537 intptr_t lib_id) {
500 Dart_Handle url = Dart_GetLibraryURL(lib_id); 538 Dart_Handle url = Dart_GetLibraryURL(lib_id);
501 RETURN_IF_ERROR(url); 539 RETURN_IF_ERROR(url);
502 buf->Printf("{\"url\":"); 540 buf->Printf("{\"url\":");
(...skipping 18 matching lines...) Expand all
521 ASSERT_NOT_ERROR(name); 559 ASSERT_NOT_ERROR(name);
522 buf->Printf("\"prefix\":\"%s\"}", 560 buf->Printf("\"prefix\":\"%s\"}",
523 Dart_IsNull(name) ? "" : GetStringChars(name)); 561 Dart_IsNull(name) ? "" : GetStringChars(name));
524 } 562 }
525 buf->Printf("],"); 563 buf->Printf("],");
526 564
527 // Global variables in the library. 565 // Global variables in the library.
528 Dart_Handle global_vars = Dart_GetLibraryFields(lib_id); 566 Dart_Handle global_vars = Dart_GetLibraryFields(lib_id);
529 RETURN_IF_ERROR(global_vars); 567 RETURN_IF_ERROR(global_vars);
530 buf->Printf("\"globals\":"); 568 buf->Printf("\"globals\":");
531 FormatFieldList(buf, global_vars); 569 FormatNamedValueList(buf, global_vars);
532 buf->Printf("}"); 570 buf->Printf("}");
533 return NULL; 571 return NULL;
534 } 572 }
535 573
536 574
537 static const char* FormatObjProps(dart::TextBuffer* buf, 575 static const char* FormatObjProps(dart::TextBuffer* buf,
538 Dart_Handle object) { 576 Dart_Handle object) {
539 intptr_t class_id; 577 intptr_t class_id;
540 if (Dart_IsNull(object)) { 578 if (Dart_IsNull(object)) {
541 buf->Printf("{\"classId\":-1,\"fields\":[]}"); 579 buf->Printf("{\"classId\":-1,\"fields\":[]}");
542 return NULL; 580 return NULL;
543 } 581 }
544 Dart_Handle res = Dart_GetObjClassId(object, &class_id); 582 Dart_Handle res = Dart_GetObjClassId(object, &class_id);
545 RETURN_IF_ERROR(res); 583 RETURN_IF_ERROR(res);
546 buf->Printf("{\"classId\": %d, \"fields\":", class_id); 584 buf->Printf("{\"classId\": %d,", class_id);
585 buf->Printf("\"kind\":\"object\",\"fields\":");
547 Dart_Handle fields = Dart_GetInstanceFields(object); 586 Dart_Handle fields = Dart_GetInstanceFields(object);
548 RETURN_IF_ERROR(fields); 587 RETURN_IF_ERROR(fields);
549 FormatFieldList(buf, fields); 588 FormatNamedValueList(buf, fields);
550 buf->Printf("}"); 589 buf->Printf("}");
551 return NULL; 590 return NULL;
552 } 591 }
553 592
554 593
594 static const char* FormatListSlice(dart::TextBuffer* buf,
595 Dart_Handle list,
596 intptr_t list_length,
597 intptr_t index,
598 intptr_t slice_length) {
599 intptr_t end_index = index + slice_length;
600 ASSERT(end_index <= list_length);
601 buf->Printf("{\"index\":%d,", index);
602 buf->Printf("\"length\":%d,", slice_length);
603 buf->Printf("\"elements\":[");
604 for (intptr_t i = index; i < end_index; i++) {
605 Dart_Handle value = Dart_ListGetAt(list, i);
606 if (i > index) {
607 buf->Printf(",");
608 }
609 FormatValueObj(buf, value);
610 }
611 buf->Printf("]}");
612 return NULL;
613 }
614
615
555 static void FormatCallFrames(dart::TextBuffer* msg, Dart_StackTrace trace) { 616 static void FormatCallFrames(dart::TextBuffer* msg, Dart_StackTrace trace) {
556 intptr_t trace_len = 0; 617 intptr_t trace_len = 0;
557 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 618 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
558 ASSERT_NOT_ERROR(res); 619 ASSERT_NOT_ERROR(res);
559 msg->Printf("\"callFrames\" : [ "); 620 msg->Printf("\"callFrames\" : [ ");
560 for (int i = 0; i < trace_len; i++) { 621 for (int i = 0; i < trace_len; i++) {
561 Dart_ActivationFrame frame; 622 Dart_ActivationFrame frame;
562 res = Dart_GetActivationFrame(trace, i, &frame); 623 res = Dart_GetActivationFrame(trace, i, &frame);
563 ASSERT_NOT_ERROR(res); 624 ASSERT_NOT_ERROR(res);
564 Dart_Handle func_name; 625 Dart_Handle func_name;
565 Dart_Handle script_url; 626 Dart_Handle script_url;
566 intptr_t line_number = 0; 627 intptr_t line_number = 0;
567 intptr_t library_id = 0; 628 intptr_t library_id = 0;
568 res = Dart_ActivationFrameInfo( 629 res = Dart_ActivationFrameInfo(
569 frame, &func_name, &script_url, &line_number, &library_id); 630 frame, &func_name, &script_url, &line_number, &library_id);
570 ASSERT_NOT_ERROR(res); 631 ASSERT_NOT_ERROR(res);
571 ASSERT(Dart_IsString(func_name)); 632 ASSERT(Dart_IsString(func_name));
572 msg->Printf("%s{\"functionName\":", (i > 0) ? "," : ""); 633 msg->Printf("%s{\"functionName\":", (i > 0) ? "," : "");
573 FormatEncodedString(msg, func_name); 634 FormatEncodedString(msg, func_name);
574 msg->Printf(",\"libraryId\": %d,", library_id); 635 msg->Printf(",\"libraryId\": %d,", library_id);
575 636
576 ASSERT(Dart_IsString(script_url)); 637 ASSERT(Dart_IsString(script_url));
577 msg->Printf("\"location\": { \"url\":"); 638 msg->Printf("\"location\": { \"url\":");
578 FormatEncodedString(msg, script_url); 639 FormatEncodedString(msg, script_url);
579 msg->Printf(",\"lineNumber\":%d},", line_number); 640 msg->Printf(",\"lineNumber\":%d},", line_number);
580 641
581 Dart_Handle locals = Dart_GetLocalVariables(frame); 642 Dart_Handle locals = Dart_GetLocalVariables(frame);
582 ASSERT_NOT_ERROR(locals); 643 ASSERT_NOT_ERROR(locals);
583 msg->Printf("\"locals\":"); 644 msg->Printf("\"locals\":");
584 FormatFieldList(msg, locals); 645 FormatNamedValueList(msg, locals);
585 msg->Printf("}"); 646 msg->Printf("}");
586 } 647 }
587 msg->Printf("]"); 648 msg->Printf("]");
588 } 649 }
589 650
590 651
591 void DebuggerConnectionHandler::HandleGetStackTraceCmd(const char* json_msg) { 652 void DebuggerConnectionHandler::HandleGetStackTraceCmd(const char* json_msg) {
592 int msg_id = msgbuf_->MessageId(); 653 int msg_id = msgbuf_->MessageId();
593 Dart_StackTrace trace; 654 Dart_StackTrace trace;
594 Dart_Handle res = Dart_GetStackTrace(&trace); 655 Dart_Handle res = Dart_GetStackTrace(&trace);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 const char* err = FormatObjProps(&msg, obj); 736 const char* err = FormatObjProps(&msg, obj);
676 if (err != NULL) { 737 if (err != NULL) {
677 SendError(msg_id, err); 738 SendError(msg_id, err);
678 return; 739 return;
679 } 740 }
680 msg.Printf("}"); 741 msg.Printf("}");
681 SendMsg(&msg); 742 SendMsg(&msg);
682 } 743 }
683 744
684 745
746 void DebuggerConnectionHandler::HandleGetListCmd(const char* json_msg) {
747 const intptr_t kDefaultSliceLength = 100;
748 int msg_id = msgbuf_->MessageId();
749 intptr_t obj_id = msgbuf_->GetIntParam("objectId");
750 Dart_Handle list = Dart_GetCachedObject(obj_id);
751 if (Dart_IsError(list)) {
752 SendError(msg_id, Dart_GetError(list));
753 return;
754 }
755 if (!Dart_IsList(list)) {
756 SendError(msg_id, "object is not a list");
757 return;
758 }
759 intptr_t list_length = 0;
760 Dart_Handle res = Dart_ListLength(list, &list_length);
761 if (Dart_IsError(res)) {
762 SendError(msg_id, Dart_GetError(res));
763 return;
764 }
765
766 intptr_t index = msgbuf_->GetIntParam("index");
767 if (index < 0) {
768 index = 0;
769 } else if (index > list_length) {
770 index = list_length;
771 }
772
773 // If no slice length is given, get only one element. If slice length
774 // is given as 0, get entire list.
775 intptr_t slice_length = msgbuf_->GetOptIntParam("length", 1);
776 if (slice_length == 0) {
777 slice_length = list_length - index;
778 }
779 if ((index + slice_length) > list_length) {
780 slice_length = list_length - index;
781 }
782 ASSERT(slice_length >= 0);
783 if (slice_length > kDefaultSliceLength) {
784 slice_length = kDefaultSliceLength;
785 }
786 dart::TextBuffer msg(64);
787 msg.Printf("{\"id\":%d, \"result\":", msg_id);
788 if (slice_length == 1) {
789 Dart_Handle value = Dart_ListGetAt(list, index);
790 FormatRemoteObj(&msg, value);
791 } else {
792 FormatListSlice(&msg, list, list_length, index, slice_length);
793 }
794 msg.Printf("}");
795 SendMsg(&msg);
796 }
797
798
685 void DebuggerConnectionHandler::HandleGetClassPropsCmd(const char* json_msg) { 799 void DebuggerConnectionHandler::HandleGetClassPropsCmd(const char* json_msg) {
686 int msg_id = msgbuf_->MessageId(); 800 int msg_id = msgbuf_->MessageId();
687 intptr_t cls_id = msgbuf_->GetIntParam("classId"); 801 intptr_t cls_id = msgbuf_->GetIntParam("classId");
688 dart::TextBuffer msg(64); 802 dart::TextBuffer msg(64);
689 msg.Printf("{\"id\":%d, \"result\":", msg_id); 803 msg.Printf("{\"id\":%d, \"result\":", msg_id);
690 const char* err = FormatClassProps(&msg, cls_id); 804 const char* err = FormatClassProps(&msg, cls_id);
691 if (err != NULL) { 805 if (err != NULL) {
692 SendError(msg_id, err); 806 SendError(msg_id, err);
693 return; 807 return;
694 } 808 }
(...skipping 17 matching lines...) Expand all
712 } 826 }
713 827
714 828
715 void DebuggerConnectionHandler::HandleGetGlobalsCmd(const char* json_msg) { 829 void DebuggerConnectionHandler::HandleGetGlobalsCmd(const char* json_msg) {
716 int msg_id = msgbuf_->MessageId(); 830 int msg_id = msgbuf_->MessageId();
717 intptr_t lib_id = msgbuf_->GetIntParam("libraryId"); 831 intptr_t lib_id = msgbuf_->GetIntParam("libraryId");
718 dart::TextBuffer msg(64); 832 dart::TextBuffer msg(64);
719 msg.Printf("{\"id\":%d, \"result\": { \"globals\":", msg_id); 833 msg.Printf("{\"id\":%d, \"result\": { \"globals\":", msg_id);
720 Dart_Handle globals = Dart_GetGlobalVariables(lib_id); 834 Dart_Handle globals = Dart_GetGlobalVariables(lib_id);
721 ASSERT_NOT_ERROR(globals); 835 ASSERT_NOT_ERROR(globals);
722 FormatFieldList(&msg, globals); 836 FormatNamedValueList(&msg, globals);
723 msg.Printf("}}"); 837 msg.Printf("}}");
724 SendMsg(&msg); 838 SendMsg(&msg);
725 } 839 }
726 840
727 841
728 void DebuggerConnectionHandler::HandleUnknownMsg(const char* json_msg) { 842 void DebuggerConnectionHandler::HandleUnknownMsg(const char* json_msg) {
729 int msg_id = msgbuf_->MessageId(); 843 int msg_id = msgbuf_->MessageId();
730 ASSERT(msg_id >= 0); 844 ASSERT(msg_id >= 0);
731 SendError(msg_id, "unknown debugger command"); 845 SendError(msg_id, "unknown debugger command");
732 } 846 }
733 847
734 848
735 void DebuggerConnectionHandler::HandleMessages() { 849 void DebuggerConnectionHandler::HandleMessages() {
736 static JSONDebuggerCommand debugger_commands[] = { 850 static JSONDebuggerCommand debugger_commands[] = {
737 { "resume", HandleResumeCmd }, 851 { "resume", HandleResumeCmd },
738 { "getLibraries", HandleGetLibrariesCmd }, 852 { "getLibraries", HandleGetLibrariesCmd },
739 { "getClassProperties", HandleGetClassPropsCmd }, 853 { "getClassProperties", HandleGetClassPropsCmd },
740 { "getLibraryProperties", HandleGetLibPropsCmd }, 854 { "getLibraryProperties", HandleGetLibPropsCmd },
741 { "getObjectProperties", HandleGetObjPropsCmd }, 855 { "getObjectProperties", HandleGetObjPropsCmd },
856 { "getListElements", HandleGetListCmd },
742 { "getGlobalVariables", HandleGetGlobalsCmd }, 857 { "getGlobalVariables", HandleGetGlobalsCmd },
743 { "getScriptURLs", HandleGetScriptURLsCmd }, 858 { "getScriptURLs", HandleGetScriptURLsCmd },
744 { "getScriptSource", HandleGetSourceCmd }, 859 { "getScriptSource", HandleGetSourceCmd },
745 { "getStackTrace", HandleGetStackTraceCmd }, 860 { "getStackTrace", HandleGetStackTraceCmd },
746 { "setBreakpoint", HandleSetBpCmd }, 861 { "setBreakpoint", HandleSetBpCmd },
747 { "setPauseOnException", HandlePauseOnExcCmd }, 862 { "setPauseOnException", HandlePauseOnExcCmd },
748 { "removeBreakpoint", HandleRemBpCmd }, 863 { "removeBreakpoint", HandleRemBpCmd },
749 { "stepInto", HandleStepIntoCmd }, 864 { "stepInto", HandleStepIntoCmd },
750 { "stepOut", HandleStepOutCmd }, 865 { "stepOut", HandleStepOutCmd },
751 { "stepOver", HandleStepOverCmd }, 866 { "stepOver", HandleStepOverCmd },
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 DebuggerConnectionImpl::StartHandler(port_number); 1024 DebuggerConnectionImpl::StartHandler(port_number);
910 Dart_SetBreakpointHandler(BreakpointHandler); 1025 Dart_SetBreakpointHandler(BreakpointHandler);
911 Dart_SetBreakpointResolvedHandler(BptResolvedHandler); 1026 Dart_SetBreakpointResolvedHandler(BptResolvedHandler);
912 Dart_SetExceptionThrownHandler(ExceptionThrownHandler); 1027 Dart_SetExceptionThrownHandler(ExceptionThrownHandler);
913 } 1028 }
914 1029
915 1030
916 DebuggerConnectionHandler::~DebuggerConnectionHandler() { 1031 DebuggerConnectionHandler::~DebuggerConnectionHandler() {
917 CloseDbgConnection(); 1032 CloseDbgConnection();
918 } 1033 }
OLDNEW
« no previous file with comments | « runtime/bin/dbg_connection.h ('k') | tools/ddbg.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698