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

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

Issue 10657048: Debugger support to display global variables (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
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 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len); 557 Dart_Handle res = Dart_StackTraceLength(trace, &trace_len);
558 ASSERT_NOT_ERROR(res); 558 ASSERT_NOT_ERROR(res);
559 msg->Printf("\"callFrames\" : [ "); 559 msg->Printf("\"callFrames\" : [ ");
560 for (int i = 0; i < trace_len; i++) { 560 for (int i = 0; i < trace_len; i++) {
561 Dart_ActivationFrame frame; 561 Dart_ActivationFrame frame;
562 res = Dart_GetActivationFrame(trace, i, &frame); 562 res = Dart_GetActivationFrame(trace, i, &frame);
563 ASSERT_NOT_ERROR(res); 563 ASSERT_NOT_ERROR(res);
564 Dart_Handle func_name; 564 Dart_Handle func_name;
565 Dart_Handle script_url; 565 Dart_Handle script_url;
566 intptr_t line_number = 0; 566 intptr_t line_number = 0;
567 intptr_t library_id = 0;
567 res = Dart_ActivationFrameInfo( 568 res = Dart_ActivationFrameInfo(
568 frame, &func_name, &script_url, &line_number); 569 frame, &func_name, &script_url, &line_number, &library_id);
569
570 ASSERT_NOT_ERROR(res); 570 ASSERT_NOT_ERROR(res);
571 ASSERT(Dart_IsString(func_name)); 571 ASSERT(Dart_IsString(func_name));
572 msg->Printf("%s{\"functionName\":", (i > 0) ? "," : ""); 572 msg->Printf("%s{\"functionName\":", (i > 0) ? "," : "");
573 FormatEncodedString(msg, func_name); 573 FormatEncodedString(msg, func_name);
574 msg->Printf(",\"libraryId\": %d,", library_id);
574 575
575 ASSERT(Dart_IsString(script_url)); 576 ASSERT(Dart_IsString(script_url));
576 msg->Printf(",\"location\": { \"url\":"); 577 msg->Printf("\"location\": { \"url\":");
577 FormatEncodedString(msg, script_url); 578 FormatEncodedString(msg, script_url);
578 msg->Printf(",\"lineNumber\":%d},", line_number); 579 msg->Printf(",\"lineNumber\":%d},", line_number);
579 580
580 Dart_Handle locals = Dart_GetLocalVariables(frame); 581 Dart_Handle locals = Dart_GetLocalVariables(frame);
581 ASSERT_NOT_ERROR(locals); 582 ASSERT_NOT_ERROR(locals);
582 msg->Printf("\"locals\":"); 583 msg->Printf("\"locals\":");
583 FormatFieldList(msg, locals); 584 FormatFieldList(msg, locals);
584 msg->Printf("}"); 585 msg->Printf("}");
585 } 586 }
586 msg->Printf("]"); 587 msg->Printf("]");
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 SendError(msg_id, err); 692 SendError(msg_id, err);
692 return; 693 return;
693 } 694 }
694 msg.Printf("}"); 695 msg.Printf("}");
695 SendMsg(&msg); 696 SendMsg(&msg);
696 } 697 }
697 698
698 699
699 void DebuggerConnectionHandler::HandleGetLibPropsCmd(const char* json_msg) { 700 void DebuggerConnectionHandler::HandleGetLibPropsCmd(const char* json_msg) {
700 int msg_id = msgbuf_->MessageId(); 701 int msg_id = msgbuf_->MessageId();
701 intptr_t cls_id = msgbuf_->GetIntParam("libraryId"); 702 intptr_t lib_id = msgbuf_->GetIntParam("libraryId");
702 dart::TextBuffer msg(64); 703 dart::TextBuffer msg(64);
703 msg.Printf("{\"id\":%d, \"result\":", msg_id); 704 msg.Printf("{\"id\":%d, \"result\":", msg_id);
704 const char* err = FormatLibraryProps(&msg, cls_id); 705 const char* err = FormatLibraryProps(&msg, lib_id);
705 if (err != NULL) { 706 if (err != NULL) {
706 SendError(msg_id, err); 707 SendError(msg_id, err);
707 return; 708 return;
708 } 709 }
709 msg.Printf("}"); 710 msg.Printf("}");
710 SendMsg(&msg); 711 SendMsg(&msg);
711 } 712 }
712 713
713 714
715 void DebuggerConnectionHandler::HandleGetGlobalsCmd(const char* json_msg) {
716 int msg_id = msgbuf_->MessageId();
717 intptr_t lib_id = msgbuf_->GetIntParam("libraryId");
718 dart::TextBuffer msg(64);
719 msg.Printf("{\"id\":%d, \"result\": { \"globals\":", msg_id);
720 Dart_Handle globals = Dart_GetGlobalVariables(lib_id);
721 ASSERT_NOT_ERROR(globals);
722 FormatFieldList(&msg, globals);
723 msg.Printf("}}");
724 SendMsg(&msg);
725 }
726
727
714 void DebuggerConnectionHandler::HandleUnknownMsg(const char* json_msg) { 728 void DebuggerConnectionHandler::HandleUnknownMsg(const char* json_msg) {
715 int msg_id = msgbuf_->MessageId(); 729 int msg_id = msgbuf_->MessageId();
716 ASSERT(msg_id >= 0); 730 ASSERT(msg_id >= 0);
717 SendError(msg_id, "unknown debugger command"); 731 SendError(msg_id, "unknown debugger command");
718 } 732 }
719 733
720 734
721 void DebuggerConnectionHandler::HandleMessages() { 735 void DebuggerConnectionHandler::HandleMessages() {
722 static JSONDebuggerCommand debugger_commands[] = { 736 static JSONDebuggerCommand debugger_commands[] = {
723 { "resume", HandleResumeCmd }, 737 { "resume", HandleResumeCmd },
724 { "getLibraries", HandleGetLibrariesCmd }, 738 { "getLibraries", HandleGetLibrariesCmd },
725 { "getClassProperties", HandleGetClassPropsCmd }, 739 { "getClassProperties", HandleGetClassPropsCmd },
726 { "getLibraryProperties", HandleGetLibPropsCmd }, 740 { "getLibraryProperties", HandleGetLibPropsCmd },
727 { "getObjectProperties", HandleGetObjPropsCmd }, 741 { "getObjectProperties", HandleGetObjPropsCmd },
742 { "getGlobalVariables", HandleGetGlobalsCmd },
728 { "getScriptURLs", HandleGetScriptURLsCmd }, 743 { "getScriptURLs", HandleGetScriptURLsCmd },
729 { "getScriptSource", HandleGetSourceCmd }, 744 { "getScriptSource", HandleGetSourceCmd },
730 { "getStackTrace", HandleGetStackTraceCmd }, 745 { "getStackTrace", HandleGetStackTraceCmd },
731 { "setBreakpoint", HandleSetBpCmd }, 746 { "setBreakpoint", HandleSetBpCmd },
732 { "setPauseOnException", HandlePauseOnExcCmd }, 747 { "setPauseOnException", HandlePauseOnExcCmd },
733 { "removeBreakpoint", HandleRemBpCmd }, 748 { "removeBreakpoint", HandleRemBpCmd },
734 { "stepInto", HandleStepIntoCmd }, 749 { "stepInto", HandleStepIntoCmd },
735 { "stepOut", HandleStepOutCmd }, 750 { "stepOut", HandleStepOutCmd },
736 { "stepOver", HandleStepOverCmd }, 751 { "stepOver", HandleStepOverCmd },
737 { NULL, NULL } 752 { NULL, NULL }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
894 DebuggerConnectionImpl::StartHandler(port_number); 909 DebuggerConnectionImpl::StartHandler(port_number);
895 Dart_SetBreakpointHandler(BreakpointHandler); 910 Dart_SetBreakpointHandler(BreakpointHandler);
896 Dart_SetBreakpointResolvedHandler(BptResolvedHandler); 911 Dart_SetBreakpointResolvedHandler(BptResolvedHandler);
897 Dart_SetExceptionThrownHandler(ExceptionThrownHandler); 912 Dart_SetExceptionThrownHandler(ExceptionThrownHandler);
898 } 913 }
899 914
900 915
901 DebuggerConnectionHandler::~DebuggerConnectionHandler() { 916 DebuggerConnectionHandler::~DebuggerConnectionHandler() {
902 CloseDbgConnection(); 917 CloseDbgConnection();
903 } 918 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698