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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 | 84 |
85 static const char* GetStringChars(Dart_Handle str) { | 85 static const char* GetStringChars(Dart_Handle str) { |
86 ASSERT(Dart_IsString(str)); | 86 ASSERT(Dart_IsString(str)); |
87 const char* chars; | 87 const char* chars; |
88 Dart_Handle res = Dart_StringToCString(str, &chars); | 88 Dart_Handle res = Dart_StringToCString(str, &chars); |
89 ASSERT(!Dart_IsError(res)); | 89 ASSERT(!Dart_IsError(res)); |
90 return chars; | 90 return chars; |
91 } | 91 } |
92 | 92 |
93 | 93 |
94 static int GetIntValue(Dart_Handle int_handle) { | 94 static int64_t GetIntValue(Dart_Handle int_handle) { |
95 int64_t int64_val = -1; | 95 int64_t int64_val = -1; |
96 ASSERT(Dart_IsInteger(int_handle)); | 96 ASSERT(Dart_IsInteger(int_handle)); |
97 Dart_Handle res = Dart_IntegerToInt64(int_handle, &int64_val); | 97 Dart_Handle res = Dart_IntegerToInt64(int_handle, &int64_val); |
98 ASSERT_NOT_ERROR(res); | 98 ASSERT_NOT_ERROR(res); |
99 // TODO(hausner): Range check. | |
100 return int64_val; | 99 return int64_val; |
101 } | 100 } |
102 | 101 |
103 | 102 |
104 char* MessageParser::GetStringParam(const char* name) const { | 103 char* MessageParser::GetStringParam(const char* name) const { |
105 const char* params = Params(); | 104 const char* params = Params(); |
106 ASSERT(params != NULL); | 105 ASSERT(params != NULL); |
107 dart::JSONReader pr(params); | 106 dart::JSONReader pr(params); |
108 pr.Seek(name); | 107 pr.Seek(name); |
109 if (pr.Type() != dart::JSONReader::kString) { | 108 if (pr.Type() != dart::JSONReader::kString) { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 is_debuggable ? "\"true\"" : "\"false\""); | 359 is_debuggable ? "\"true\"" : "\"false\""); |
361 | 360 |
362 // Imports and prefixes. | 361 // Imports and prefixes. |
363 Dart_Handle import_list = Dart_GetLibraryImports(lib_id); | 362 Dart_Handle import_list = Dart_GetLibraryImports(lib_id); |
364 RETURN_IF_ERROR(import_list); | 363 RETURN_IF_ERROR(import_list); |
365 ASSERT(Dart_IsList(import_list)); | 364 ASSERT(Dart_IsList(import_list)); |
366 intptr_t list_length = 0; | 365 intptr_t list_length = 0; |
367 res = Dart_ListLength(import_list, &list_length); | 366 res = Dart_ListLength(import_list, &list_length); |
368 RETURN_IF_ERROR(res); | 367 RETURN_IF_ERROR(res); |
369 buf->Printf(",\"imports\":["); | 368 buf->Printf(",\"imports\":["); |
370 for (int i = 0; i + 1 < list_length; i += 2) { | 369 for (intptr_t i = 0; i + 1 < list_length; i += 2) { |
371 Dart_Handle lib_id = Dart_ListGetAt(import_list, i + 1); | 370 Dart_Handle lib_id = Dart_ListGetAt(import_list, i + 1); |
372 ASSERT_NOT_ERROR(lib_id); | 371 ASSERT_NOT_ERROR(lib_id); |
373 buf->Printf("%s{\"libraryId\":%d,", | 372 buf->Printf("%s{\"libraryId\":%" Pd64 ",", |
374 (i > 0) ? ",": "", | 373 (i > 0) ? ",": "", |
375 GetIntValue(lib_id)); | 374 GetIntValue(lib_id)); |
376 | 375 |
377 Dart_Handle name = Dart_ListGetAt(import_list, i); | 376 Dart_Handle name = Dart_ListGetAt(import_list, i); |
378 ASSERT_NOT_ERROR(name); | 377 ASSERT_NOT_ERROR(name); |
379 buf->Printf("\"prefix\":\"%s\"}", | 378 buf->Printf("\"prefix\":\"%s\"}", |
380 Dart_IsNull(name) ? "" : GetStringChars(name)); | 379 Dart_IsNull(name) ? "" : GetStringChars(name)); |
381 } | 380 } |
382 buf->Printf("],"); | 381 buf->Printf("],"); |
383 | 382 |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 ASSERT(in_msg != NULL); | 572 ASSERT(in_msg != NULL); |
574 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); | 573 MessageParser msg_parser(in_msg->buffer(), in_msg->buffer_len()); |
575 int msg_id = msg_parser.MessageId(); | 574 int msg_id = msg_parser.MessageId(); |
576 dart::TextBuffer msg(64); | 575 dart::TextBuffer msg(64); |
577 msg.Printf("{ \"id\": %d, \"result\": { \"libraries\": [", msg_id); | 576 msg.Printf("{ \"id\": %d, \"result\": { \"libraries\": [", msg_id); |
578 Dart_Handle lib_ids = Dart_GetLibraryIds(); | 577 Dart_Handle lib_ids = Dart_GetLibraryIds(); |
579 ASSERT_NOT_ERROR(lib_ids); | 578 ASSERT_NOT_ERROR(lib_ids); |
580 intptr_t num_libs; | 579 intptr_t num_libs; |
581 Dart_Handle res = Dart_ListLength(lib_ids, &num_libs); | 580 Dart_Handle res = Dart_ListLength(lib_ids, &num_libs); |
582 ASSERT_NOT_ERROR(res); | 581 ASSERT_NOT_ERROR(res); |
583 for (int i = 0; i < num_libs; i++) { | 582 for (intptr_t i = 0; i < num_libs; i++) { |
584 Dart_Handle lib_id_handle = Dart_ListGetAt(lib_ids, i); | 583 Dart_Handle lib_id_handle = Dart_ListGetAt(lib_ids, i); |
585 ASSERT(Dart_IsInteger(lib_id_handle)); | 584 ASSERT(Dart_IsInteger(lib_id_handle)); |
586 int lib_id = GetIntValue(lib_id_handle); | 585 int64_t lib_id = GetIntValue(lib_id_handle); |
587 Dart_Handle lib_url = Dart_GetLibraryURL(lib_id); | 586 ASSERT((lib_id >= kIntptrMin) && (lib_id <= kIntptrMax)); |
| 587 Dart_Handle lib_url = Dart_GetLibraryURL(static_cast<intptr_t>(lib_id)); |
588 ASSERT_NOT_ERROR(lib_url); | 588 ASSERT_NOT_ERROR(lib_url); |
589 ASSERT(Dart_IsString(lib_url)); | 589 ASSERT(Dart_IsString(lib_url)); |
590 msg.Printf("%s{\"id\":%d,\"url\":", (i == 0) ? "" : ", ", lib_id); | 590 msg.Printf("%s{\"id\":%" Pd64 ",\"url\":", (i == 0) ? "" : ", ", lib_id); |
591 FormatEncodedString(&msg, lib_url); | 591 FormatEncodedString(&msg, lib_url); |
592 msg.Printf("}"); | 592 msg.Printf("}"); |
593 } | 593 } |
594 msg.Printf("]}}"); | 594 msg.Printf("]}}"); |
595 in_msg->SendReply(&msg); | 595 in_msg->SendReply(&msg); |
596 return false; | 596 return false; |
597 } | 597 } |
598 | 598 |
599 | 599 |
600 bool DbgMessage::HandleGetClassPropsCmd(DbgMessage* in_msg) { | 600 bool DbgMessage::HandleGetClassPropsCmd(DbgMessage* in_msg) { |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 msg.Printf("\"result\": { \"lines\": ["); | 891 msg.Printf("\"result\": { \"lines\": ["); |
892 Dart_Handle elem; | 892 Dart_Handle elem; |
893 intptr_t num_elems = 0; | 893 intptr_t num_elems = 0; |
894 for (intptr_t i = 0; i < info_len; i++) { | 894 for (intptr_t i = 0; i < info_len; i++) { |
895 elem = Dart_ListGetAt(info, i); | 895 elem = Dart_ListGetAt(info, i); |
896 if (Dart_IsNull(elem)) { | 896 if (Dart_IsNull(elem)) { |
897 msg.Printf((i == 0) ? "[" : "], ["); | 897 msg.Printf((i == 0) ? "[" : "], ["); |
898 num_elems = 0; | 898 num_elems = 0; |
899 } else { | 899 } else { |
900 ASSERT(Dart_IsInteger(elem)); | 900 ASSERT(Dart_IsInteger(elem)); |
901 int value = GetIntValue(elem); | 901 int64_t value = GetIntValue(elem); |
902 if (num_elems == 0) { | 902 if (num_elems == 0) { |
903 msg.Printf("%d", value); | 903 msg.Printf("%" Pd64 "", value); |
904 } else { | 904 } else { |
905 msg.Printf(",%d", value); | 905 msg.Printf(",%" Pd64 "", value); |
906 } | 906 } |
907 num_elems++; | 907 num_elems++; |
908 } | 908 } |
909 } | 909 } |
910 msg.Printf("]]}}"); | 910 msg.Printf("]]}}"); |
911 in_msg->SendReply(&msg); | 911 in_msg->SendReply(&msg); |
912 return false; | 912 return false; |
913 } | 913 } |
914 | 914 |
915 | 915 |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1369 } else { | 1369 } else { |
1370 ASSERT(kind == kShutdown); | 1370 ASSERT(kind == kShutdown); |
1371 RemoveIsolateMsgQueue(isolate_id); | 1371 RemoveIsolateMsgQueue(isolate_id); |
1372 } | 1372 } |
1373 } | 1373 } |
1374 Dart_ExitScope(); | 1374 Dart_ExitScope(); |
1375 } | 1375 } |
1376 | 1376 |
1377 } // namespace bin | 1377 } // namespace bin |
1378 } // namespace dart | 1378 } // namespace dart |
OLD | NEW |