X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2Fexperimental%2Fsymbolizer%2FSignalHandler.cpp;h=06173c08f2be89d997f0e22fcc40fafe349158e6;hp=7719c5d4640a24f85b06dfddedd5040ff4f45f0b;hb=cb3a7e4572affb970e7491a94c9503b6a2745d1e;hpb=a1614feea3f3c0beb75fb2dc43ec45b3e5d57223 diff --git a/folly/experimental/symbolizer/SignalHandler.cpp b/folly/experimental/symbolizer/SignalHandler.cpp index 7719c5d4..06173c08 100644 --- a/folly/experimental/symbolizer/SignalHandler.cpp +++ b/folly/experimental/symbolizer/SignalHandler.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015 Facebook, Inc. + * Copyright 2016 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,14 +18,15 @@ #include +#include +#include #include -#include +#include + +#include #include #include #include -#include -#include -#include #include #include @@ -34,7 +35,9 @@ #include #include #include +#include #include +#include namespace folly { namespace symbolizer { @@ -95,13 +98,13 @@ struct { const char* name; struct sigaction oldAction; } kFatalSignals[] = { - { SIGSEGV, "SIGSEGV" }, - { SIGILL, "SIGILL" }, - { SIGFPE, "SIGFPE" }, - { SIGABRT, "SIGABRT" }, - { SIGBUS, "SIGBUS" }, - { SIGTERM, "SIGTERM" }, - { 0, nullptr } + { SIGSEGV, "SIGSEGV", {} }, + { SIGILL, "SIGILL", {} }, + { SIGFPE, "SIGFPE", {} }, + { SIGABRT, "SIGABRT", {} }, + { SIGBUS, "SIGBUS", {} }, + { SIGTERM, "SIGTERM", {} }, + { 0, nullptr, {} } }; void callPreviousSignalHandler(int signum) { @@ -124,13 +127,13 @@ void callPreviousSignalHandler(int signum) { raise(signum); } -constexpr size_t kDefaultCapacity = 500; - // Note: not thread-safe, but that's okay, as we only let one thread // in our signal handler at a time. // // Leak it so we don't have to worry about destruction order -auto gSignalSafeElfCache = new SignalSafeElfCache(kDefaultCapacity); +constexpr size_t kMinSignalSafeElfCacheSize = 500; +auto gSignalSafeElfCache = new SignalSafeElfCache( + std::max(countLoadedElfFiles(), kMinSignalSafeElfCacheSize)); // Buffered writer (using a fixed-size buffer). We try to write only once // to prevent interleaving with messages written from other threads. @@ -393,7 +396,9 @@ void dumpStackTrace(bool symbolize) { if (!getStackTraceSafe(addresses)) { print("(error retrieving stack trace)\n"); } else if (symbolize) { - Symbolizer symbolizer(gSignalSafeElfCache); + // Do our best to populate location info, process is going to terminate, + // so performance isn't critical. + Symbolizer symbolizer(gSignalSafeElfCache, Dwarf::LocationInfoMode::FULL); symbolizer.symbolize(addresses); // Skip the top 2 frames: