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

Unified Diff: runtime/vm/profiler.cc

Issue 2514113002: Dump stack trace on segfault in the VM. (Closed)
Patch Set: comment Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/profiler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/profiler.cc
diff --git a/runtime/vm/profiler.cc b/runtime/vm/profiler.cc
index 22febb0dabbe8ba3a1fefe4ecea920912cc93028..c7ed3b1961686ad89c1c4a756719ebd7a87d8bfc 100644
--- a/runtime/vm/profiler.cc
+++ b/runtime/vm/profiler.cc
@@ -944,7 +944,36 @@ static uintptr_t __attribute__((noinline)) GetProgramCounter() {
#endif
+void Profiler::DumpStackTrace(void* context) {
+#if defined(TARGET_OS_LINUX) || defined(TARGET_OS_MACOS)
+ ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
+ mcontext_t mcontext = ucontext->uc_mcontext;
+ uword pc = SignalHandler::GetProgramCounter(mcontext);
+ uword fp = SignalHandler::GetFramePointer(mcontext);
+ uword sp = SignalHandler::GetCStackPointer(mcontext);
+ DumpStackTrace(/* native_stack_trace = */ true, sp, fp, pc);
+#else
+// TODO(fschneider): Add support for more platforms.
+// Do nothing on unsupported platforms.
+#endif
+}
+
+
void Profiler::DumpStackTrace(bool native_stack_trace) {
+ uintptr_t sp = Thread::GetCurrentStackPointer();
+ uintptr_t fp = 0;
+ uintptr_t pc = GetProgramCounter();
+
+ COPY_FP_REGISTER(fp);
+
+ DumpStackTrace(native_stack_trace, sp, fp, pc);
+}
+
+
+void Profiler::DumpStackTrace(bool native_stack_trace,
+ uword sp,
+ uword fp,
+ uword pc) {
// Allow only one stack trace to prevent recursively printing stack traces if
// we hit an assert while printing the stack.
static uintptr_t started_dump = 0;
@@ -970,12 +999,6 @@ void Profiler::DumpStackTrace(bool native_stack_trace) {
native_stack_trace ? "native" : "dart-only",
OSThread::ThreadIdToIntPtr(os_thread->trace_id()));
- uintptr_t sp = Thread::GetCurrentStackPointer();
- uintptr_t fp = 0;
- uintptr_t pc = GetProgramCounter();
-
- COPY_FP_REGISTER(fp);
-
uword stack_lower = 0;
uword stack_upper = 0;
« no previous file with comments | « runtime/vm/profiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698