| 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 "include/dart_debugger_api.h" | 5 #include "include/dart_debugger_api.h" |
| 6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
| 7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/unit_test.h" | 8 #include "vm/unit_test.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 | 35 |
| 36 static char const* ToCString(Dart_Handle str) { | 36 static char const* ToCString(Dart_Handle str) { |
| 37 EXPECT(Dart_IsString(str)); | 37 EXPECT(Dart_IsString(str)); |
| 38 char const* c_str = NULL; | 38 char const* c_str = NULL; |
| 39 Dart_StringToCString(str, &c_str); | 39 Dart_StringToCString(str, &c_str); |
| 40 return c_str; | 40 return c_str; |
| 41 } | 41 } |
| 42 | 42 |
| 43 | 43 |
| 44 static char const* BPFunctionName(Dart_StackTrace trace) { | |
| 45 Dart_ActivationFrame frame; | |
| 46 Dart_Handle res = Dart_GetActivationFrame(trace, 0, &frame); | |
| 47 EXPECT_NOT_ERROR(res); | |
| 48 Dart_Handle func_name; | |
| 49 res = Dart_ActivationFrameInfo(frame, &func_name, NULL, NULL); | |
| 50 EXPECT_NOT_ERROR(res); | |
| 51 return ToCString(func_name); | |
| 52 } | |
| 53 | |
| 54 | |
| 55 static char const* BreakpointInfo(Dart_StackTrace trace) { | 44 static char const* BreakpointInfo(Dart_StackTrace trace) { |
| 56 static char info_str[128]; | 45 static char info_str[128]; |
| 57 Dart_ActivationFrame frame; | 46 Dart_ActivationFrame frame; |
| 58 Dart_Handle res = Dart_GetActivationFrame(trace, 0, &frame); | 47 Dart_Handle res = Dart_GetActivationFrame(trace, 0, &frame); |
| 59 EXPECT_NOT_ERROR(res); | 48 EXPECT_NOT_ERROR(res); |
| 60 Dart_Handle func_name; | 49 Dart_Handle func_name; |
| 61 Dart_Handle url; | 50 Dart_Handle url; |
| 62 intptr_t line_number = 0; | 51 intptr_t line_number = 0; |
| 63 res = Dart_ActivationFrameInfo(frame, &func_name, &url, &line_number); | 52 res = Dart_ActivationFrameInfo(frame, &func_name, &url, &line_number); |
| 64 EXPECT_NOT_ERROR(res); | 53 EXPECT_NOT_ERROR(res); |
| 65 OS::SNPrint(info_str, sizeof(info_str), "function %s (%s:%d)", | 54 OS::SNPrint(info_str, sizeof(info_str), "function %s (%s:%d)", |
| 66 ToCString(func_name), ToCString(url), line_number); | 55 ToCString(func_name), ToCString(url), line_number); |
| 67 return info_str; | 56 return info_str; |
| 68 } | 57 } |
| 69 | 58 |
| 70 | 59 |
| 71 static void PrintValue(Dart_Handle value, bool expand); | 60 static void PrintValue(Dart_Handle value, bool expand); |
| 72 | 61 |
| 73 | 62 |
| 74 static void PrintObjectList(Dart_Handle list, const char* prefix, bool expand) { | 63 static void PrintObjectList(Dart_Handle list, const char* prefix, bool expand) { |
| 75 intptr_t list_length = 0; | 64 intptr_t list_length = 0; |
| 76 Dart_Handle retval = Dart_ListLength(list, &list_length); | 65 Dart_Handle retval = Dart_ListLength(list, &list_length); |
| 66 EXPECT_NOT_ERROR(retval); |
| 77 for (int i = 0; i + 1 < list_length; i += 2) { | 67 for (int i = 0; i + 1 < list_length; i += 2) { |
| 78 Dart_Handle name_handle = Dart_ListGetAt(list, i); | 68 Dart_Handle name_handle = Dart_ListGetAt(list, i); |
| 79 EXPECT_NOT_ERROR(name_handle); | 69 EXPECT_NOT_ERROR(name_handle); |
| 80 EXPECT(Dart_IsString(name_handle)); | 70 EXPECT(Dart_IsString(name_handle)); |
| 81 Dart_Handle value_handle = Dart_ListGetAt(list, i + 1); | 71 Dart_Handle value_handle = Dart_ListGetAt(list, i + 1); |
| 82 OS::Print("\n %s %s = ", prefix, ToCString(name_handle)); | 72 OS::Print("\n %s %s = ", prefix, ToCString(name_handle)); |
| 83 PrintValue(value_handle, expand); | 73 PrintValue(value_handle, expand); |
| 84 } | 74 } |
| 85 } | 75 } |
| 86 | 76 |
| (...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 EXPECT(Dart_IsString(source)); | 800 EXPECT(Dart_IsString(source)); |
| 811 char const* source_chars; | 801 char const* source_chars; |
| 812 Dart_StringToCString(source, &source_chars); | 802 Dart_StringToCString(source, &source_chars); |
| 813 OS::Print("\n=== source: ===\n%s", source_chars); | 803 OS::Print("\n=== source: ===\n%s", source_chars); |
| 814 EXPECT_STREQ(kScriptChars, source_chars); | 804 EXPECT_STREQ(kScriptChars, source_chars); |
| 815 } | 805 } |
| 816 | 806 |
| 817 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 807 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
| 818 | 808 |
| 819 } // namespace dart | 809 } // namespace dart |
| OLD | NEW |