From dfd471eea24cb4307091374515b30633bdbfb62a Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Mon, 30 Jan 2017 16:38:50 -0800 Subject: [PATCH] Make the segfault handler attempt to symbolize Dart frames. R=fschneider@google.com Review-Url: https://codereview.chromium.org/2668443004 . --- runtime/bin/platform_linux.cc | 4 ++++ runtime/bin/platform_macos.cc | 4 ++++ runtime/vm/profiler.cc | 34 ++++++++++++++-------------------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/runtime/bin/platform_linux.cc b/runtime/bin/platform_linux.cc index 0d3338c9158..e69466a2b0b 100644 --- a/runtime/bin/platform_linux.cc +++ b/runtime/bin/platform_linux.cc @@ -54,6 +54,10 @@ bool Platform::Initialize() { perror("sigaction() failed."); return false; } + if (sigaction(SIGTRAP, &act, NULL) != 0) { + perror("sigaction() failed."); + return false; + } return true; } diff --git a/runtime/bin/platform_macos.cc b/runtime/bin/platform_macos.cc index 0c6de4ddac9..537bb1ec222 100644 --- a/runtime/bin/platform_macos.cc +++ b/runtime/bin/platform_macos.cc @@ -59,6 +59,10 @@ bool Platform::Initialize() { perror("sigaction() failed."); return false; } + if (sigaction(SIGTRAP, &act, NULL) != 0) { + perror("sigaction() failed."); + return false; + } return true; } diff --git a/runtime/vm/profiler.cc b/runtime/vm/profiler.cc index 9db93ae0cfe..2e99b34d7ee 100644 --- a/runtime/vm/profiler.cc +++ b/runtime/vm/profiler.cc @@ -330,6 +330,20 @@ void ClearProfileVisitor::VisitSample(Sample* sample) { static void DumpStackFrame(intptr_t frame_index, uword pc) { + Isolate* isolate = Isolate::Current(); + if ((isolate != NULL) && isolate->is_runnable()) { + Code& code = Code::Handle(Code::LookupCodeInVmIsolate(pc)); + if (!code.IsNull()) { + OS::PrintErr(" [0x%" Pp "] %s\n", pc, code.QualifiedName()); + return; + } + code = Code::LookupCode(pc); + if (!code.IsNull()) { + OS::PrintErr(" [0x%" Pp "] %s\n", pc, code.QualifiedName()); + return; + } + } + uintptr_t start = 0; char* native_symbol_name = NativeSymbolResolver::LookupSymbolName(pc, &start); if (native_symbol_name == NULL) { @@ -341,16 +355,6 @@ static void DumpStackFrame(intptr_t frame_index, uword pc) { } -static void DumpStackFrame(intptr_t frame_index, uword pc, const Code& code) { - if (code.IsNull()) { - DumpStackFrame(frame_index, pc); - } else { - OS::PrintErr("Frame[%" Pd "] = Dart:`%s` [0x%" Px "]\n", frame_index, - code.ToCString(), pc); - } -} - - class ProfilerStackWalker : public ValueObject { public: ProfilerStackWalker(Isolate* isolate, @@ -370,16 +374,6 @@ class ProfilerStackWalker : public ValueObject { } } - bool Append(uword pc, const Code& code) { - if (sample_ == NULL) { - DumpStackFrame(frame_index_, pc, code); - frame_index_++; - total_frames_++; - return true; - } - return Append(pc); - } - bool Append(uword pc) { if (sample_ == NULL) { DumpStackFrame(frame_index_, pc);