| OLD | NEW |
| 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/dbg_message.h" | 6 #include "bin/dbg_message.h" |
| 7 #include "bin/dartutils.h" | 7 #include "bin/dartutils.h" |
| 8 #include "bin/thread.h" | 8 #include "bin/thread.h" |
| 9 #include "bin/utils.h" | 9 #include "bin/utils.h" |
| 10 | 10 |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 { "stepOver", DbgMessage::HandleStepOverCmd }, | 472 { "stepOver", DbgMessage::HandleStepOverCmd }, |
| 473 { "getLibraries", DbgMessage::HandleGetLibrariesCmd }, | 473 { "getLibraries", DbgMessage::HandleGetLibrariesCmd }, |
| 474 { "getClassProperties", DbgMessage::HandleGetClassPropsCmd }, | 474 { "getClassProperties", DbgMessage::HandleGetClassPropsCmd }, |
| 475 { "getLibraryProperties", DbgMessage::HandleGetLibPropsCmd }, | 475 { "getLibraryProperties", DbgMessage::HandleGetLibPropsCmd }, |
| 476 { "setLibraryProperties", DbgMessage::HandleSetLibPropsCmd }, | 476 { "setLibraryProperties", DbgMessage::HandleSetLibPropsCmd }, |
| 477 { "getObjectProperties", DbgMessage::HandleGetObjPropsCmd }, | 477 { "getObjectProperties", DbgMessage::HandleGetObjPropsCmd }, |
| 478 { "getListElements", DbgMessage::HandleGetListCmd }, | 478 { "getListElements", DbgMessage::HandleGetListCmd }, |
| 479 { "getGlobalVariables", DbgMessage::HandleGetGlobalsCmd }, | 479 { "getGlobalVariables", DbgMessage::HandleGetGlobalsCmd }, |
| 480 { "getScriptURLs", DbgMessage::HandleGetScriptURLsCmd }, | 480 { "getScriptURLs", DbgMessage::HandleGetScriptURLsCmd }, |
| 481 { "getScriptSource", DbgMessage::HandleGetSourceCmd }, | 481 { "getScriptSource", DbgMessage::HandleGetSourceCmd }, |
| 482 { "getLineNumberTable", DbgMessage::HandleGetLineNumbersCmd }, |
| 482 { "getStackTrace", DbgMessage::HandleGetStackTraceCmd }, | 483 { "getStackTrace", DbgMessage::HandleGetStackTraceCmd }, |
| 483 { "setBreakpoint", DbgMessage::HandleSetBpCmd }, | 484 { "setBreakpoint", DbgMessage::HandleSetBpCmd }, |
| 484 { "setPauseOnException", DbgMessage::HandlePauseOnExcCmd }, | 485 { "setPauseOnException", DbgMessage::HandlePauseOnExcCmd }, |
| 485 { "removeBreakpoint", DbgMessage::HandleRemBpCmd }, | 486 { "removeBreakpoint", DbgMessage::HandleRemBpCmd }, |
| 486 { NULL, NULL } | 487 { NULL, NULL } |
| 487 }; | 488 }; |
| 488 | 489 |
| 489 | 490 |
| 490 bool DbgMessage::HandleMessage() { | 491 bool DbgMessage::HandleMessage() { |
| 491 // Dispatch to the appropriate handler for the command. | 492 // Dispatch to the appropriate handler for the command. |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 } | 782 } |
| 782 msg.Printf("{ \"id\": %d, ", msg_id); | 783 msg.Printf("{ \"id\": %d, ", msg_id); |
| 783 msg.Printf("\"result\": { \"text\": "); | 784 msg.Printf("\"result\": { \"text\": "); |
| 784 FormatEncodedString(&msg, source); | 785 FormatEncodedString(&msg, source); |
| 785 msg.Printf("}}"); | 786 msg.Printf("}}"); |
| 786 in_msg->SendReply(&msg); | 787 in_msg->SendReply(&msg); |
| 787 return false; | 788 return false; |
| 788 } | 789 } |
| 789 | 790 |
| 790 | 791 |
| 792 bool DbgMessage::HandleGetLineNumbersCmd(DbgMessage* in_msg) { |
| 793 ASSERT(in_msg != NULL); |
| 794 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); |
| 795 int msg_id = msg_parser.MessageId(); |
| 796 dart::TextBuffer msg(64); |
| 797 intptr_t lib_id = msg_parser.GetIntParam("libraryId"); |
| 798 char* url_chars = msg_parser.GetStringParam("url"); |
| 799 ASSERT(url_chars != NULL); |
| 800 Dart_Handle url = DartUtils::NewString(url_chars); |
| 801 ASSERT_NOT_ERROR(url); |
| 802 free(url_chars); |
| 803 url_chars = NULL; |
| 804 Dart_Handle info = Dart_ScriptGetTokenInfo(lib_id, url); |
| 805 if (Dart_IsError(info)) { |
| 806 in_msg->SendErrorReply(msg_id, Dart_GetError(info)); |
| 807 return false; |
| 808 } |
| 809 ASSERT(Dart_IsList(info)); |
| 810 intptr_t info_len = 0; |
| 811 Dart_Handle res = Dart_ListLength(info, &info_len); |
| 812 ASSERT_NOT_ERROR(res); |
| 813 msg.Printf("{ \"id\": %d, ", msg_id); |
| 814 msg.Printf("\"result\": { \"lines\": ["); |
| 815 Dart_Handle elem; |
| 816 bool num_elems = 0; |
| 817 for (intptr_t i = 0; i < info_len; i++) { |
| 818 elem = Dart_ListGetAt(info, i); |
| 819 if (Dart_IsNull(elem)) { |
| 820 msg.Printf((i == 0) ? "[" : "], ["); |
| 821 num_elems = 0; |
| 822 } else { |
| 823 ASSERT(Dart_IsInteger(elem)); |
| 824 int value = GetIntValue(elem); |
| 825 if (num_elems == 0) { |
| 826 msg.Printf("%d", value); |
| 827 } else { |
| 828 msg.Printf(",%d", value); |
| 829 } |
| 830 num_elems++; |
| 831 } |
| 832 } |
| 833 msg.Printf("]]}}"); |
| 834 in_msg->SendReply(&msg); |
| 835 return false; |
| 836 } |
| 837 |
| 838 |
| 791 bool DbgMessage::HandleGetStackTraceCmd(DbgMessage* in_msg) { | 839 bool DbgMessage::HandleGetStackTraceCmd(DbgMessage* in_msg) { |
| 792 ASSERT(in_msg != NULL); | 840 ASSERT(in_msg != NULL); |
| 793 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); | 841 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); |
| 794 int msg_id = msg_parser.MessageId(); | 842 int msg_id = msg_parser.MessageId(); |
| 795 Dart_StackTrace trace; | 843 Dart_StackTrace trace; |
| 796 Dart_Handle res = Dart_GetStackTrace(&trace); | 844 Dart_Handle res = Dart_GetStackTrace(&trace); |
| 797 ASSERT_NOT_ERROR(res); | 845 ASSERT_NOT_ERROR(res); |
| 798 dart::TextBuffer msg(128); | 846 dart::TextBuffer msg(128); |
| 799 msg.Printf("{ \"id\": %d, \"result\": {", msg_id); | 847 msg.Printf("{ \"id\": %d, \"result\": {", msg_id); |
| 800 FormatCallFrames(&msg, trace); | 848 FormatCallFrames(&msg, trace); |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1179 msg_queue->SendIsolateEvent(isolate_id, kind); | 1227 msg_queue->SendIsolateEvent(isolate_id, kind); |
| 1180 if (kind == kInterrupted) { | 1228 if (kind == kInterrupted) { |
| 1181 msg_queue->HandleMessages(); | 1229 msg_queue->HandleMessages(); |
| 1182 } else { | 1230 } else { |
| 1183 ASSERT(kind == kShutdown); | 1231 ASSERT(kind == kShutdown); |
| 1184 RemoveIsolateMsgQueue(isolate_id); | 1232 RemoveIsolateMsgQueue(isolate_id); |
| 1185 } | 1233 } |
| 1186 } | 1234 } |
| 1187 Dart_ExitScope(); | 1235 Dart_ExitScope(); |
| 1188 } | 1236 } |
| OLD | NEW |