From f49e65ae7c1d696be6b81be6bf838fb05ff84ab8 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Thu, 10 Nov 2011 18:31:53 +0000 Subject: [PATCH] Made the Host::SetCrashDescription(const char *) function copy the incoming string to avoid possible later crashes. Modified the locations that do set the crash description to NULL out the string when they are done doing their tasks. llvm-svn: 144297 --- lldb/source/API/SBFrame.cpp | 2 ++ lldb/source/Host/macosx/Host.mm | 16 ++++++++++++++-- .../Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 2 ++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index f72f8bfacf4b..300ae2edd0c2 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -765,6 +765,8 @@ SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dyna keep_in_memory, fetch_dynamic_value, *expr_result); + + Host::SetCrashDescription (NULL); } if (expr_log) diff --git a/lldb/source/Host/macosx/Host.mm b/lldb/source/Host/macosx/Host.mm index 0b09d35ff1f6..c8df2e9b37da 100644 --- a/lldb/source/Host/macosx/Host.mm +++ b/lldb/source/Host/macosx/Host.mm @@ -503,7 +503,10 @@ LaunchInNewTerminalWithAppleScript (const char *exe_path, ProcessLaunchInfo &lau { const char *shell_executable = getenv("SHELL"); std::string safe_arg; - command.Printf(" -- %s -c '", shell_executable); + if (launch_info.GetArchitecture().IsValid()) + command.Printf(" -- %s -c 'exec /usr/bin/arch -arch %s ", shell_executable, launch_info.GetArchitecture().GetArchitectureName()); + else + command.Printf(" -- %s -c 'exec ", shell_executable); const char **argv = launch_info.GetArguments().GetConstArgumentVector (); if (argv) { @@ -644,7 +647,16 @@ void Host::SetCrashDescription (const char *cstr) { Mutex::Locker locker (GetCrashReporterMutex ()); - __crashreporter_info__ = cstr; + 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 diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index d10e25484fdd..b7f63ae7737f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -4585,6 +4585,8 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu, is_artificial); LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(cxx_method_decl), die); + Host::SetCrashDescription (NULL); + type_handled = cxx_method_decl != NULL; } }