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

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

Issue 10797033: Debugger API to enable/disable debugging of libraries (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') | runtime/include/dart_debugger_api.h » ('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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 536 }
537 537
538 538
539 static const char* FormatLibraryProps(dart::TextBuffer* buf, 539 static const char* FormatLibraryProps(dart::TextBuffer* buf,
540 intptr_t lib_id) { 540 intptr_t lib_id) {
541 Dart_Handle url = Dart_GetLibraryURL(lib_id); 541 Dart_Handle url = Dart_GetLibraryURL(lib_id);
542 RETURN_IF_ERROR(url); 542 RETURN_IF_ERROR(url);
543 buf->Printf("{\"url\":"); 543 buf->Printf("{\"url\":");
544 FormatEncodedString(buf, url); 544 FormatEncodedString(buf, url);
545 545
546 // Whether debugging is enabled.
547 bool is_debuggable = false;
548 Dart_Handle res = Dart_GetLibraryDebuggable(lib_id, &is_debuggable);
549 RETURN_IF_ERROR(res);
550 buf->Printf(",\"debuggingEnabled\":%s",
551 is_debuggable ? "\"true\"" : "\"false\"");
552
546 // Imports and prefixes. 553 // Imports and prefixes.
547 Dart_Handle import_list = Dart_GetLibraryImports(lib_id); 554 Dart_Handle import_list = Dart_GetLibraryImports(lib_id);
548 RETURN_IF_ERROR(import_list); 555 RETURN_IF_ERROR(import_list);
549 ASSERT(Dart_IsList(import_list)); 556 ASSERT(Dart_IsList(import_list));
550 intptr_t list_length = 0; 557 intptr_t list_length = 0;
551 Dart_Handle res = Dart_ListLength(import_list, &list_length); 558 res = Dart_ListLength(import_list, &list_length);
552 RETURN_IF_ERROR(res); 559 RETURN_IF_ERROR(res);
553 buf->Printf(",\"imports\":["); 560 buf->Printf(",\"imports\":[");
554 for (int i = 0; i + 1 < list_length; i += 2) { 561 for (int i = 0; i + 1 < list_length; i += 2) {
555 Dart_Handle lib_id = Dart_ListGetAt(import_list, i + 1); 562 Dart_Handle lib_id = Dart_ListGetAt(import_list, i + 1);
556 ASSERT_NOT_ERROR(lib_id); 563 ASSERT_NOT_ERROR(lib_id);
557 buf->Printf("%s{\"libraryId\":%d,", 564 buf->Printf("%s{\"libraryId\":%d,",
558 (i > 0) ? ",": "", 565 (i > 0) ? ",": "",
559 GetIntValue(lib_id)); 566 GetIntValue(lib_id));
560 567
561 Dart_Handle name = Dart_ListGetAt(import_list, i); 568 Dart_Handle name = Dart_ListGetAt(import_list, i);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 const char* err = FormatLibraryProps(&msg, lib_id); 829 const char* err = FormatLibraryProps(&msg, lib_id);
823 if (err != NULL) { 830 if (err != NULL) {
824 SendError(msg_id, err); 831 SendError(msg_id, err);
825 return; 832 return;
826 } 833 }
827 msg.Printf("}"); 834 msg.Printf("}");
828 SendMsg(&msg); 835 SendMsg(&msg);
829 } 836 }
830 837
831 838
839 void DebuggerConnectionHandler::HandleSetLibPropsCmd(const char* json_msg) {
840 int msg_id = msgbuf_->MessageId();
841 intptr_t lib_id = msgbuf_->GetIntParam("libraryId");
842 const char* enable_request = msgbuf_->GetStringParam("debuggingEnabled");
843 bool enable;
844 if (strcmp(enable_request, "true") == 0) {
845 enable = true;
846 } else if (strcmp(enable_request, "false") == 0) {
847 enable = false;
848 } else {
849 SendError(msg_id, "illegal argument for 'debuggingEnabled'");
850 return;
851 }
852 Dart_Handle res = Dart_SetLibraryDebuggable(lib_id, enable);
853 if (Dart_IsError(res)) {
854 SendError(msg_id, Dart_GetError(res));
855 return;
856 }
857 bool enabled = false;
858 res = Dart_GetLibraryDebuggable(lib_id, &enabled);
859 if (Dart_IsError(res)) {
860 SendError(msg_id, Dart_GetError(res));
861 return;
862 }
863 dart::TextBuffer msg(64);
864 msg.Printf("{\"id\":%d, \"result\": {\"debuggingEnabled\": \"%s\"}}",
865 msg_id,
866 enabled ? "true" : "false");
867 SendMsg(&msg);
868 }
869
870
832 void DebuggerConnectionHandler::HandleGetGlobalsCmd(const char* json_msg) { 871 void DebuggerConnectionHandler::HandleGetGlobalsCmd(const char* json_msg) {
833 int msg_id = msgbuf_->MessageId(); 872 int msg_id = msgbuf_->MessageId();
834 intptr_t lib_id = msgbuf_->GetIntParam("libraryId"); 873 intptr_t lib_id = msgbuf_->GetIntParam("libraryId");
835 dart::TextBuffer msg(64); 874 dart::TextBuffer msg(64);
836 msg.Printf("{\"id\":%d, \"result\": { \"globals\":", msg_id); 875 msg.Printf("{\"id\":%d, \"result\": { \"globals\":", msg_id);
837 Dart_Handle globals = Dart_GetGlobalVariables(lib_id); 876 Dart_Handle globals = Dart_GetGlobalVariables(lib_id);
838 ASSERT_NOT_ERROR(globals); 877 ASSERT_NOT_ERROR(globals);
839 FormatNamedValueList(&msg, globals); 878 FormatNamedValueList(&msg, globals);
840 msg.Printf("}}"); 879 msg.Printf("}}");
841 SendMsg(&msg); 880 SendMsg(&msg);
842 } 881 }
843 882
844 883
845 void DebuggerConnectionHandler::HandleUnknownMsg(const char* json_msg) { 884 void DebuggerConnectionHandler::HandleUnknownMsg(const char* json_msg) {
846 int msg_id = msgbuf_->MessageId(); 885 int msg_id = msgbuf_->MessageId();
847 ASSERT(msg_id >= 0); 886 ASSERT(msg_id >= 0);
848 SendError(msg_id, "unknown debugger command"); 887 SendError(msg_id, "unknown debugger command");
849 } 888 }
850 889
851 890
852 void DebuggerConnectionHandler::HandleMessages() { 891 void DebuggerConnectionHandler::HandleMessages() {
853 static JSONDebuggerCommand debugger_commands[] = { 892 static JSONDebuggerCommand debugger_commands[] = {
854 { "resume", HandleResumeCmd }, 893 { "resume", HandleResumeCmd },
855 { "getLibraries", HandleGetLibrariesCmd }, 894 { "getLibraries", HandleGetLibrariesCmd },
856 { "getClassProperties", HandleGetClassPropsCmd }, 895 { "getClassProperties", HandleGetClassPropsCmd },
857 { "getLibraryProperties", HandleGetLibPropsCmd }, 896 { "getLibraryProperties", HandleGetLibPropsCmd },
897 { "setLibraryProperties", HandleSetLibPropsCmd },
858 { "getObjectProperties", HandleGetObjPropsCmd }, 898 { "getObjectProperties", HandleGetObjPropsCmd },
859 { "getListElements", HandleGetListCmd }, 899 { "getListElements", HandleGetListCmd },
860 { "getGlobalVariables", HandleGetGlobalsCmd }, 900 { "getGlobalVariables", HandleGetGlobalsCmd },
861 { "getScriptURLs", HandleGetScriptURLsCmd }, 901 { "getScriptURLs", HandleGetScriptURLsCmd },
862 { "getScriptSource", HandleGetSourceCmd }, 902 { "getScriptSource", HandleGetSourceCmd },
863 { "getStackTrace", HandleGetStackTraceCmd }, 903 { "getStackTrace", HandleGetStackTraceCmd },
864 { "setBreakpoint", HandleSetBpCmd }, 904 { "setBreakpoint", HandleSetBpCmd },
865 { "setPauseOnException", HandlePauseOnExcCmd }, 905 { "setPauseOnException", HandlePauseOnExcCmd },
866 { "removeBreakpoint", HandleRemBpCmd }, 906 { "removeBreakpoint", HandleRemBpCmd },
867 { "stepInto", HandleStepIntoCmd }, 907 { "stepInto", HandleStepIntoCmd },
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 DebuggerConnectionImpl::StartHandler(port_number); 1067 DebuggerConnectionImpl::StartHandler(port_number);
1028 Dart_SetBreakpointHandler(BreakpointHandler); 1068 Dart_SetBreakpointHandler(BreakpointHandler);
1029 Dart_SetBreakpointResolvedHandler(BptResolvedHandler); 1069 Dart_SetBreakpointResolvedHandler(BptResolvedHandler);
1030 Dart_SetExceptionThrownHandler(ExceptionThrownHandler); 1070 Dart_SetExceptionThrownHandler(ExceptionThrownHandler);
1031 } 1071 }
1032 1072
1033 1073
1034 DebuggerConnectionHandler::~DebuggerConnectionHandler() { 1074 DebuggerConnectionHandler::~DebuggerConnectionHandler() {
1035 CloseDbgConnection(); 1075 CloseDbgConnection();
1036 } 1076 }
OLDNEW
« no previous file with comments | « runtime/bin/dbg_connection.h ('k') | runtime/include/dart_debugger_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698