| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "vm/isolate.h" | 5 #include "vm/isolate.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "platform/json.h" | 9 #include "platform/json.h" |
| 10 #include "lib/mirrors.h" | 10 #include "lib/mirrors.h" |
| (...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 TextBuffer buffer(256); | 883 TextBuffer buffer(256); |
| 884 buffer.Printf("{ \"handle\": \"0x%" Px64 "\", \"stacktrace\": [ ", | 884 buffer.Printf("{ \"handle\": \"0x%" Px64 "\", \"stacktrace\": [ ", |
| 885 reinterpret_cast<int64_t>(isolate)); | 885 reinterpret_cast<int64_t>(isolate)); |
| 886 intptr_t n_frames = stack->Length(); | 886 intptr_t n_frames = stack->Length(); |
| 887 String& url = String::Handle(); | 887 String& url = String::Handle(); |
| 888 String& function = String::Handle(); | 888 String& function = String::Handle(); |
| 889 for (int i = 0; i < n_frames; i++) { | 889 for (int i = 0; i < n_frames; i++) { |
| 890 if (i > 0) { | 890 if (i > 0) { |
| 891 buffer.Printf(", "); | 891 buffer.Printf(", "); |
| 892 } | 892 } |
| 893 ActivationFrame* frame = stack->ActivationFrameAt(i); | 893 ActivationFrame* frame = stack->FrameAt(i); |
| 894 url ^= frame->SourceUrl(); | 894 url ^= frame->SourceUrl(); |
| 895 function ^= frame->function().UserVisibleName(); | 895 function ^= frame->function().UserVisibleName(); |
| 896 buffer.Printf("{ \"url\": \"%s\", ", url.ToCString()); | 896 buffer.Printf("{ \"url\": \"%s\", ", url.ToCString()); |
| 897 buffer.Printf("\"line\": %" Pd ", ", frame->LineNumber()); | 897 buffer.Printf("\"line\": %" Pd ", ", frame->LineNumber()); |
| 898 buffer.Printf("\"function\": \"%s\", ", function.ToCString()); | 898 buffer.Printf("\"function\": \"%s\", ", function.ToCString()); |
| 899 | 899 |
| 900 const Code& code = frame->code(); | 900 const Code& code = frame->code(); |
| 901 buffer.Printf("\"code\": { "); | 901 buffer.Printf("\"code\": { "); |
| 902 buffer.Printf("\"alive\": %s, ", code.is_alive() ? "false" : "true"); | 902 buffer.Printf("\"alive\": %s, ", code.is_alive() ? "false" : "true"); |
| 903 buffer.Printf("\"optimized\": %s }}", | 903 buffer.Printf("\"optimized\": %s }}", |
| 904 code.is_optimized() ? "false" : "true"); | 904 code.is_optimized() ? "false" : "true"); |
| 905 } | 905 } |
| 906 buffer.Printf("]}"); | 906 buffer.Printf("]}"); |
| 907 isolate->stacktrace_ = OS::StrNDup(buffer.buf(), buffer.length()); | 907 isolate->stacktrace_ = OS::StrNDup(buffer.buf(), buffer.length()); |
| 908 ml.Notify(); | 908 ml.Notify(); |
| 909 return true; | 909 return true; |
| 910 } | 910 } |
| 911 | 911 |
| 912 | 912 |
| 913 bool Isolate::FetchStackFrameDetails() { | 913 bool Isolate::FetchStackFrameDetails() { |
| 914 Isolate* isolate = Isolate::Current(); | 914 Isolate* isolate = Isolate::Current(); |
| 915 ASSERT(isolate->stack_frame_index_ >= 0); | 915 ASSERT(isolate->stack_frame_index_ >= 0); |
| 916 MonitorLocker ml(status_sync); | 916 MonitorLocker ml(status_sync); |
| 917 DebuggerStackTrace* stack = Debugger::CollectStackTrace(); | 917 DebuggerStackTrace* stack = Debugger::CollectStackTrace(); |
| 918 intptr_t frame_index = isolate->stack_frame_index_; | 918 intptr_t frame_index = isolate->stack_frame_index_; |
| 919 if (frame_index >= stack->Length()) { | 919 if (frame_index >= stack->Length()) { |
| 920 // Frame no longer available. | 920 // Frame no longer available. |
| 921 return NULL; | 921 return NULL; |
| 922 } | 922 } |
| 923 ActivationFrame* frame = stack->ActivationFrameAt(frame_index); | 923 ActivationFrame* frame = stack->FrameAt(frame_index); |
| 924 TextBuffer buffer(256); | 924 TextBuffer buffer(256); |
| 925 buffer.Printf("{ \"handle\": \"0x%" Px64 "\", \"frame_index\": %" Pd ", ", | 925 buffer.Printf("{ \"handle\": \"0x%" Px64 "\", \"frame_index\": %" Pd ", ", |
| 926 reinterpret_cast<int64_t>(isolate), frame_index); | 926 reinterpret_cast<int64_t>(isolate), frame_index); |
| 927 | 927 |
| 928 const Code& code = frame->code(); | 928 const Code& code = frame->code(); |
| 929 buffer.Printf("\"code\": { \"size\": %" Pd ", ", code.Size()); | 929 buffer.Printf("\"code\": { \"size\": %" Pd ", ", code.Size()); |
| 930 buffer.Printf("\"alive\": %s, ", code.is_alive() ? "false" : "true"); | 930 buffer.Printf("\"alive\": %s, ", code.is_alive() ? "false" : "true"); |
| 931 buffer.Printf("\"optimized\": %s }, ", | 931 buffer.Printf("\"optimized\": %s }, ", |
| 932 code.is_optimized() ? "false" : "true"); | 932 code.is_optimized() ? "false" : "true"); |
| 933 // TODO(tball): add compilation stats (time, etc.), when available. | 933 // TODO(tball): add compilation stats (time, etc.), when available. |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1185 return func.raw(); | 1185 return func.raw(); |
| 1186 } | 1186 } |
| 1187 | 1187 |
| 1188 | 1188 |
| 1189 void IsolateSpawnState::Cleanup() { | 1189 void IsolateSpawnState::Cleanup() { |
| 1190 SwitchIsolateScope switch_scope(isolate()); | 1190 SwitchIsolateScope switch_scope(isolate()); |
| 1191 Dart::ShutdownIsolate(); | 1191 Dart::ShutdownIsolate(); |
| 1192 } | 1192 } |
| 1193 | 1193 |
| 1194 } // namespace dart | 1194 } // namespace dart |
| OLD | NEW |