Index: lldb/trunk/include/lldb/Host/Host.h =================================================================== --- lldb/trunk/include/lldb/Host/Host.h +++ lldb/trunk/include/lldb/Host/Host.h @@ -183,23 +183,6 @@ //------------------------------------------------------------------ static bool ResolveExecutableInBundle(FileSpec &file); - //------------------------------------------------------------------ - /// Set a string that can be displayed if host application crashes. - /// - /// Some operating systems have the ability to print a description - /// for shared libraries when a program crashes. If the host OS - /// supports such a mechanism, it should be implemented to help - /// with crash triage. - /// - /// @param[in] format - /// A printf format that will be used to form a new crash - /// description string. - //------------------------------------------------------------------ - static void SetCrashDescriptionWithFormat(const char *format, ...) - __attribute__((format(printf, 1, 2))); - - static void SetCrashDescription(const char *description); - static uint32_t FindProcesses(const ProcessInstanceInfoMatch &match_info, ProcessInstanceInfoList &proc_infos); Index: lldb/trunk/scripts/Xcode/build-llvm.py =================================================================== --- lldb/trunk/scripts/Xcode/build-llvm.py +++ lldb/trunk/scripts/Xcode/build-llvm.py @@ -346,7 +346,8 @@ "-DCMAKE_C_FLAGS={}".format(get_c_flags()), "-DCMAKE_CXX_FLAGS={}".format(get_cxx_flags()), "-DCMAKE_EXE_LINKER_FLAGS={}".format(get_exe_linker_flags()), - "-DCMAKE_SHARED_LINKER_FLAGS={}".format(get_shared_linker_flags())] + "-DCMAKE_SHARED_LINKER_FLAGS={}".format(get_shared_linker_flags()), + "-DHAVE_CRASHREPORTER_INFO=1"] deployment_target = get_deployment_target() if deployment_target: cmake_flags.append( Index: lldb/trunk/source/API/SBFrame.cpp =================================================================== --- lldb/trunk/source/API/SBFrame.cpp +++ lldb/trunk/source/API/SBFrame.cpp @@ -52,6 +52,8 @@ #include "lldb/API/SBValue.h" #include "lldb/API/SBVariablesOptions.h" +#include "llvm/Support/PrettyStackTrace.h" + using namespace lldb; using namespace lldb_private; @@ -1288,10 +1290,11 @@ if (stop_locker.TryLock(&process->GetRunLock())) { frame = exe_ctx.GetFramePtr(); if (frame) { + std::unique_ptr PST; if (target->GetDisplayExpressionsInCrashlogs()) { StreamString frame_description; frame->DumpUsingSettingsFormat(&frame_description); - Host::SetCrashDescriptionWithFormat( + PST = llvm::make_unique( "SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value " "= %u) %s", expr, options.GetFetchDynamicValue(), @@ -1301,9 +1304,6 @@ exe_results = target->EvaluateExpression(expr, frame, expr_value_sp, options.ref()); expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); - - if (target->GetDisplayExpressionsInCrashlogs()) - Host::SetCrashDescription(nullptr); } else { if (log) log->Printf("SBFrame::EvaluateExpression () => error: could not " Index: lldb/trunk/source/API/SBTarget.cpp =================================================================== --- lldb/trunk/source/API/SBTarget.cpp +++ lldb/trunk/source/API/SBTarget.cpp @@ -64,6 +64,7 @@ #include "../source/Commands/CommandObjectBreakpoint.h" #include "lldb/Interpreter/CommandReturnObject.h" +#include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Regex.h" using namespace lldb; @@ -2129,7 +2130,7 @@ StreamString frame_description; if (frame) frame->DumpUsingSettingsFormat(&frame_description); - Host::SetCrashDescriptionWithFormat( + llvm::PrettyStackTraceFormat PST( "SBTarget::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = " "%u) %s", expr, options.GetFetchDynamicValue(), @@ -2139,9 +2140,6 @@ target->EvaluateExpression(expr, frame, expr_value_sp, options.ref()); expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); -#ifdef LLDB_CONFIGURATION_DEBUG - Host::SetCrashDescription(NULL); -#endif } else { if (log) log->Printf("SBTarget::EvaluateExpression () => error: could not " Index: lldb/trunk/source/Host/common/Host.cpp =================================================================== --- lldb/trunk/source/Host/common/Host.cpp +++ lldb/trunk/source/Host/common/Host.cpp @@ -999,10 +999,6 @@ return false; } -void Host::SetCrashDescriptionWithFormat(const char *format, ...) {} - -void Host::SetCrashDescription(const char *description) {} - #endif const UnixSignalsSP &Host::GetUnixSignals() { Index: lldb/trunk/source/Host/macosx/Host.mm =================================================================== --- lldb/trunk/source/Host/macosx/Host.mm +++ lldb/trunk/source/Host/macosx/Host.mm @@ -537,47 +537,6 @@ #endif // #if !defined(__arm__) && !defined(__arm64__) && !defined(__aarch64__) -// On MacOSX CrashReporter will display a string for each shared library if -// the shared library has an exported symbol named "__crashreporter_info__". - -static std::mutex &GetCrashReporterMutex() { - static std::mutex g_mutex; - return g_mutex; -} - -extern "C" { -const char *__crashreporter_info__ = NULL; -} - -asm(".desc ___crashreporter_info__, 0x10"); - -void Host::SetCrashDescriptionWithFormat(const char *format, ...) { - static StreamString g_crash_description; - std::lock_guard guard(GetCrashReporterMutex()); - - if (format) { - va_list args; - va_start(args, format); - g_crash_description.GetString() = llvm::StringRef(""); - g_crash_description.PrintfVarArg(format, args); - va_end(args); - __crashreporter_info__ = g_crash_description.GetData(); - } else { - __crashreporter_info__ = NULL; - } -} - -void Host::SetCrashDescription(const char *cstr) { - std::lock_guard guard(GetCrashReporterMutex()); - static std::string g_crash_description; - if (cstr) { - g_crash_description.assign(cstr); - __crashreporter_info__ = g_crash_description.c_str(); - } else { - __crashreporter_info__ = NULL; - } -} - bool Host::OpenFileInExternalEditor(const FileSpec &file_spec, uint32_t line_no) { #if defined(__arm__) || defined(__arm64__) || defined(__aarch64__) Index: lldb/trunk/source/Initialization/SystemInitializerCommon.cpp =================================================================== --- lldb/trunk/source/Initialization/SystemInitializerCommon.cpp +++ lldb/trunk/source/Initialization/SystemInitializerCommon.cpp @@ -35,18 +35,13 @@ #include "lldb/Host/windows/windows.h" #endif +#include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/TargetSelect.h" #include using namespace lldb_private; -static void fatal_error_handler(void *user_data, const std::string &reason, - bool gen_crash_diag) { - Host::SetCrashDescription(reason.c_str()); - ::abort(); -} - SystemInitializerCommon::SystemInitializerCommon() {} SystemInitializerCommon::~SystemInitializerCommon() {} @@ -74,12 +69,11 @@ } #endif + llvm::EnablePrettyStackTrace(); Log::Initialize(); HostInfo::Initialize(); Timer scoped_timer(LLVM_PRETTY_FUNCTION, LLVM_PRETTY_FUNCTION); - llvm::install_fatal_error_handler(fatal_error_handler, 0); - process_gdb_remote::ProcessGDBRemoteLog::Initialize(); // Initialize plug-ins Index: lldb/trunk/source/Interpreter/CommandInterpreter.cpp =================================================================== --- lldb/trunk/source/Interpreter/CommandInterpreter.cpp +++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp @@ -72,6 +72,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/Path.h" +#include "llvm/Support/PrettyStackTrace.h" using namespace lldb; using namespace lldb_private; @@ -1526,13 +1527,8 @@ std::string original_command_string(command_line); Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_COMMANDS)); - Host::SetCrashDescriptionWithFormat("HandleCommand(command = \"%s\")", - command_line); - - // Make a scoped cleanup object that will clear the crash description string - // on exit of this function. - lldb_utility::CleanUp crash_description_cleanup( - nullptr, Host::SetCrashDescription); + llvm::PrettyStackTraceFormat PST("HandleCommand(command = \"%s\")", + command_line); if (log) log->Printf("Processing command: %s", command_line); Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp =================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -1473,8 +1473,7 @@ } if (add_method) { - // REMOVE THE CRASH DESCRIPTION BELOW - Host::SetCrashDescriptionWithFormat( + llvm::PrettyStackTraceFormat PST( "SymbolFileDWARF::ParseType() is adding a method " "%s to class %s in DIE 0x%8.8" PRIx64 " from %s", type_name_cstr, @@ -1492,12 +1491,12 @@ if (accessibility == eAccessNone) accessibility = eAccessPublic; - clang::CXXMethodDecl *cxx_method_decl; - cxx_method_decl = m_ast.AddMethodToCXXRecordType( - class_opaque_type.GetOpaqueQualType(), - type_name_cstr, clang_type, accessibility, - is_virtual, is_static, is_inline, is_explicit, - is_attr_used, is_artificial); + clang::CXXMethodDecl *cxx_method_decl = + m_ast.AddMethodToCXXRecordType( + class_opaque_type.GetOpaqueQualType(), + type_name_cstr, clang_type, accessibility, + is_virtual, is_static, is_inline, is_explicit, + is_attr_used, is_artificial); type_handled = cxx_method_decl != NULL; @@ -1507,8 +1506,6 @@ cxx_method_decl), die); - Host::SetCrashDescription(NULL); - ClangASTMetadata metadata; metadata.SetUserID(die.GetID());