Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: runtime/vm/profiler.cc

Issue 2813283002: Add --print_stacktrace_at_api_error. (Closed)
Patch Set: . Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 857 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 ASSERT(isolate != NULL); 868 ASSERT(isolate != NULL);
869 Simulator* simulator = isolate->simulator(); 869 Simulator* simulator = isolate->simulator();
870 *stack_lower = simulator->StackBase(); 870 *stack_lower = simulator->StackBase();
871 *stack_upper = simulator->StackTop(); 871 *stack_upper = simulator->StackTop();
872 } 872 }
873 #else 873 #else
874 const bool use_simulator_stack_bounds = false; 874 const bool use_simulator_stack_bounds = false;
875 #endif 875 #endif
876 876
877 if (!use_simulator_stack_bounds && 877 if (!use_simulator_stack_bounds &&
878 !os_thread->GetProfilerStackBounds(stack_lower, stack_upper) &&
879 !(get_os_thread_bounds && 878 !(get_os_thread_bounds &&
880 OSThread::GetCurrentStackBounds(stack_lower, stack_upper))) { 879 OSThread::GetCurrentStackBounds(stack_lower, stack_upper)) &&
880 !os_thread->GetProfilerStackBounds(stack_lower, stack_upper)) {
881 // Could not get stack boundary. 881 // Could not get stack boundary.
882 return false; 882 return false;
883 } 883 }
884 884
885 if ((*stack_lower == 0) || (*stack_upper == 0)) { 885 if ((*stack_lower == 0) || (*stack_upper == 0)) {
886 return false; 886 return false;
887 } 887 }
888 888
889 if (!use_simulator_stack_bounds && (sp > *stack_lower)) { 889 if (!use_simulator_stack_bounds && (sp > *stack_lower)) {
890 // The stack pointer gives us a tighter lower bound. 890 // The stack pointer gives us a tighter lower bound.
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 } 962 }
963 963
964 964
965 void Profiler::DumpStackTrace(void* context) { 965 void Profiler::DumpStackTrace(void* context) {
966 #if defined(HOST_OS_LINUX) || defined(HOST_OS_MACOS) 966 #if defined(HOST_OS_LINUX) || defined(HOST_OS_MACOS)
967 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); 967 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
968 mcontext_t mcontext = ucontext->uc_mcontext; 968 mcontext_t mcontext = ucontext->uc_mcontext;
969 uword pc = SignalHandler::GetProgramCounter(mcontext); 969 uword pc = SignalHandler::GetProgramCounter(mcontext);
970 uword fp = SignalHandler::GetFramePointer(mcontext); 970 uword fp = SignalHandler::GetFramePointer(mcontext);
971 uword sp = SignalHandler::GetCStackPointer(mcontext); 971 uword sp = SignalHandler::GetCStackPointer(mcontext);
972 DumpStackTrace(sp, fp, pc); 972 DumpStackTrace(sp, fp, pc, true /* for_crash */);
973 #else 973 #else
974 // TODO(fschneider): Add support for more platforms. 974 // TODO(fschneider): Add support for more platforms.
975 // Do nothing on unsupported platforms. 975 // Do nothing on unsupported platforms.
976 #endif 976 #endif
977 } 977 }
978 978
979 979
980 void Profiler::DumpStackTrace() { 980 void Profiler::DumpStackTrace(bool for_crash) {
981 uintptr_t sp = Thread::GetCurrentStackPointer(); 981 uintptr_t sp = Thread::GetCurrentStackPointer();
982 uintptr_t fp = 0; 982 uintptr_t fp = 0;
983 uintptr_t pc = OS::GetProgramCounter(); 983 uintptr_t pc = OS::GetProgramCounter();
984 984
985 COPY_FP_REGISTER(fp); 985 COPY_FP_REGISTER(fp);
986 986
987 DumpStackTrace(sp, fp, pc); 987 DumpStackTrace(sp, fp, pc, for_crash);
988 } 988 }
989 989
990 990
991 void Profiler::DumpStackTrace(uword sp, uword fp, uword pc) { 991 void Profiler::DumpStackTrace(uword sp, uword fp, uword pc, bool for_crash) {
992 // Allow only one stack trace to prevent recursively printing stack traces if 992 if (for_crash) {
993 // we hit an assert while printing the stack. 993 // Allow only one stack trace to prevent recursively printing stack traces
994 static uintptr_t started_dump = 0; 994 // if we hit an assert while printing the stack.
995 if (AtomicOperations::FetchAndIncrement(&started_dump) != 0) { 995 static uintptr_t started_dump = 0;
996 OS::PrintErr("Aborting re-entrant request for stack trace.\n"); 996 if (AtomicOperations::FetchAndIncrement(&started_dump) != 0) {
997 return; 997 OS::PrintErr("Aborting re-entrant request for stack trace.\n");
998 return;
999 }
998 } 1000 }
siva 2017/04/13 01:50:18 Why is this logic relevant only when for_crash is
999 1001
1000 Thread* thread = Thread::Current(); 1002 Thread* thread = Thread::Current();
1001 if (thread == NULL) { 1003 if (thread == NULL) {
1002 return; 1004 return;
1003 } 1005 }
1004 OSThread* os_thread = thread->os_thread(); 1006 OSThread* os_thread = thread->os_thread();
1005 ASSERT(os_thread != NULL); 1007 ASSERT(os_thread != NULL);
1006 Isolate* isolate = thread->isolate(); 1008 Isolate* isolate = thread->isolate();
1007 if (!CheckIsolate(isolate)) { 1009 if (!CheckIsolate(isolate)) {
1008 return; 1010 return;
(...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after
1602 1604
1603 1605
1604 ProcessedSampleBuffer::ProcessedSampleBuffer() 1606 ProcessedSampleBuffer::ProcessedSampleBuffer()
1605 : code_lookup_table_(new CodeLookupTable(Thread::Current())) { 1607 : code_lookup_table_(new CodeLookupTable(Thread::Current())) {
1606 ASSERT(code_lookup_table_ != NULL); 1608 ASSERT(code_lookup_table_ != NULL);
1607 } 1609 }
1608 1610
1609 #endif // !PRODUCT 1611 #endif // !PRODUCT
1610 1612
1611 } // namespace dart 1613 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/profiler.h ('k') | runtime/vm/thread_pool.cc » ('j') | runtime/vm/thread_pool.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698