| 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 "platform/address_sanitizer.h" | 5 #include "platform/address_sanitizer.h" |
| 6 #include "platform/memory_sanitizer.h" | 6 #include "platform/memory_sanitizer.h" |
| 7 #include "platform/utils.h" | 7 #include "platform/utils.h" |
| 8 | 8 |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 #include "vm/atomic.h" | 10 #include "vm/atomic.h" |
| (...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1028 | 1028 |
| 1029 static bool CheckIsolate(Isolate* isolate) { | 1029 static bool CheckIsolate(Isolate* isolate) { |
| 1030 if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) { | 1030 if ((isolate == NULL) || (Dart::vm_isolate() == NULL)) { |
| 1031 // No isolate. | 1031 // No isolate. |
| 1032 return false; | 1032 return false; |
| 1033 } | 1033 } |
| 1034 return isolate != Dart::vm_isolate(); | 1034 return isolate != Dart::vm_isolate(); |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 void Profiler::DumpStackTrace(void* context) { | 1037 void Profiler::DumpStackTrace(void* context) { |
| 1038 #if defined(HOST_OS_LINUX) || defined(HOST_OS_MACOS) | 1038 #if defined(HOST_OS_LINUX) || defined(HOST_OS_MACOS) || defined(HOST_OS_ANDROID) |
| 1039 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); | 1039 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); |
| 1040 mcontext_t mcontext = ucontext->uc_mcontext; | 1040 mcontext_t mcontext = ucontext->uc_mcontext; |
| 1041 uword pc = SignalHandler::GetProgramCounter(mcontext); | 1041 uword pc = SignalHandler::GetProgramCounter(mcontext); |
| 1042 uword fp = SignalHandler::GetFramePointer(mcontext); | 1042 uword fp = SignalHandler::GetFramePointer(mcontext); |
| 1043 uword sp = SignalHandler::GetCStackPointer(mcontext); | 1043 uword sp = SignalHandler::GetCStackPointer(mcontext); |
| 1044 DumpStackTrace(sp, fp, pc, true /* for_crash */); | 1044 DumpStackTrace(sp, fp, pc, true /* for_crash */); |
| 1045 #elif defined(HOST_OS_WINDOWS) | 1045 #elif defined(HOST_OS_WINDOWS) |
| 1046 CONTEXT* ctx = reinterpret_cast<CONTEXT*>(context); | 1046 CONTEXT* ctx = reinterpret_cast<CONTEXT*>(context); |
| 1047 #if defined(HOST_ARCH_IA32) | 1047 #if defined(HOST_ARCH_IA32) |
| 1048 uword pc = static_cast<uword>(ctx->Eip); | 1048 uword pc = static_cast<uword>(ctx->Eip); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1078 // if we hit an assert while printing the stack. | 1078 // if we hit an assert while printing the stack. |
| 1079 static uintptr_t started_dump = 0; | 1079 static uintptr_t started_dump = 0; |
| 1080 if (AtomicOperations::FetchAndIncrement(&started_dump) != 0) { | 1080 if (AtomicOperations::FetchAndIncrement(&started_dump) != 0) { |
| 1081 OS::PrintErr("Aborting re-entrant request for stack trace.\n"); | 1081 OS::PrintErr("Aborting re-entrant request for stack trace.\n"); |
| 1082 return; | 1082 return; |
| 1083 } | 1083 } |
| 1084 } | 1084 } |
| 1085 | 1085 |
| 1086 Thread* thread = Thread::Current(); | 1086 Thread* thread = Thread::Current(); |
| 1087 if (thread == NULL) { | 1087 if (thread == NULL) { |
| 1088 OS::PrintErr("Stack dump aborted because no current Dart thread.\n"); |
| 1088 return; | 1089 return; |
| 1089 } | 1090 } |
| 1090 OSThread* os_thread = thread->os_thread(); | 1091 OSThread* os_thread = thread->os_thread(); |
| 1091 ASSERT(os_thread != NULL); | 1092 ASSERT(os_thread != NULL); |
| 1092 Isolate* isolate = thread->isolate(); | 1093 Isolate* isolate = thread->isolate(); |
| 1093 if (!CheckIsolate(isolate)) { | 1094 if (!CheckIsolate(isolate)) { |
| 1095 OS::PrintErr("Stack dump aborted because CheckIsolate failed.\n"); |
| 1094 return; | 1096 return; |
| 1095 } | 1097 } |
| 1096 | 1098 |
| 1097 OS::PrintErr("Dumping native stack trace for thread %" Px "\n", | 1099 OS::PrintErr("Dumping native stack trace for thread %" Px "\n", |
| 1098 OSThread::ThreadIdToIntPtr(os_thread->trace_id())); | 1100 OSThread::ThreadIdToIntPtr(os_thread->trace_id())); |
| 1099 | 1101 |
| 1100 uword stack_lower = 0; | 1102 uword stack_lower = 0; |
| 1101 uword stack_upper = 0; | 1103 uword stack_upper = 0; |
| 1102 | 1104 |
| 1103 if (!InitialRegisterCheck(pc, fp, sp)) { | 1105 if (!InitialRegisterCheck(pc, fp, sp)) { |
| 1104 OS::PrintErr("Stack dump aborted because InitialRegisterCheck.\n"); | 1106 OS::PrintErr("Stack dump aborted because InitialRegisterCheck failed.\n"); |
| 1105 return; | 1107 return; |
| 1106 } | 1108 } |
| 1107 | 1109 |
| 1108 if (!GetAndValidateThreadStackBounds(thread, fp, sp, &stack_lower, | 1110 if (!GetAndValidateThreadStackBounds(thread, fp, sp, &stack_lower, |
| 1109 &stack_upper, | 1111 &stack_upper, |
| 1110 /*get_os_thread_bounds=*/true)) { | 1112 /*get_os_thread_bounds=*/true)) { |
| 1111 OS::PrintErr( | 1113 OS::PrintErr( |
| 1112 "Stack dump aborted because GetAndValidateThreadStackBounds.\n"); | 1114 "Stack dump aborted because GetAndValidateThreadStackBounds failed.\n"); |
| 1113 return; | 1115 return; |
| 1114 } | 1116 } |
| 1115 | 1117 |
| 1116 ProfilerNativeStackWalker native_stack_walker( | 1118 ProfilerNativeStackWalker native_stack_walker( |
| 1117 (isolate != NULL) ? isolate->main_port() : ILLEGAL_PORT, NULL, NULL, | 1119 (isolate != NULL) ? isolate->main_port() : ILLEGAL_PORT, NULL, NULL, |
| 1118 stack_lower, stack_upper, pc, fp, sp); | 1120 stack_lower, stack_upper, pc, fp, sp); |
| 1119 native_stack_walker.walk(); | 1121 native_stack_walker.walk(); |
| 1120 OS::PrintErr("-- End of DumpStackTrace\n"); | 1122 OS::PrintErr("-- End of DumpStackTrace\n"); |
| 1121 } | 1123 } |
| 1122 | 1124 |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1679 } | 1681 } |
| 1680 | 1682 |
| 1681 ProcessedSampleBuffer::ProcessedSampleBuffer() | 1683 ProcessedSampleBuffer::ProcessedSampleBuffer() |
| 1682 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { | 1684 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { |
| 1683 ASSERT(code_lookup_table_ != NULL); | 1685 ASSERT(code_lookup_table_ != NULL); |
| 1684 } | 1686 } |
| 1685 | 1687 |
| 1686 #endif // !PRODUCT | 1688 #endif // !PRODUCT |
| 1687 | 1689 |
| 1688 } // namespace dart | 1690 } // namespace dart |
| OLD | NEW |