From owner-svn-src-all@FreeBSD.ORG Tue Feb 25 21:42:23 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4DDEC43F; Tue, 25 Feb 2014 21:42:23 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 357CF1D94; Tue, 25 Feb 2014 21:42:23 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s1PLgNqX032280; Tue, 25 Feb 2014 21:42:23 GMT (envelope-from emaste@svn.freebsd.org) Received: (from emaste@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s1PLgHcu032238; Tue, 25 Feb 2014 21:42:17 GMT (envelope-from emaste@svn.freebsd.org) Message-Id: <201402252142.s1PLgHcu032238@svn.freebsd.org> From: Ed Maste Date: Tue, 25 Feb 2014 21:42:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r262497 - in vendor/lldb/dist: include/lldb include/lldb/Core include/lldb/Host include/lldb/Interpreter include/lldb/Symbol include/lldb/Target source/API source/Core source/Expression... X-SVN-Group: vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Feb 2014 21:42:23 -0000 Author: emaste Date: Tue Feb 25 21:42:16 2014 New Revision: 262497 URL: http://svnweb.freebsd.org/changeset/base/262497 Log: Import LLDB as of SVN r202189 (git 32871eb) (A number of files not required for the FreeBSD build have been removed.) Sponsored by: DARPA, AFRL Modified: vendor/lldb/dist/include/lldb/Core/ArchSpec.h vendor/lldb/dist/include/lldb/Core/IOHandler.h vendor/lldb/dist/include/lldb/Host/HostGetOpt.h vendor/lldb/dist/include/lldb/Interpreter/PythonDataObjects.h vendor/lldb/dist/include/lldb/Symbol/VariableList.h vendor/lldb/dist/include/lldb/Target/Process.h vendor/lldb/dist/include/lldb/lldb-enumerations.h vendor/lldb/dist/source/API/SBFrame.cpp vendor/lldb/dist/source/Core/ArchSpec.cpp vendor/lldb/dist/source/Core/Debugger.cpp vendor/lldb/dist/source/Core/IOHandler.cpp vendor/lldb/dist/source/Expression/ClangExpressionDeclMap.cpp vendor/lldb/dist/source/Host/common/Host.cpp vendor/lldb/dist/source/Interpreter/PythonDataObjects.cpp vendor/lldb/dist/source/Interpreter/ScriptInterpreterPython.cpp vendor/lldb/dist/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp vendor/lldb/dist/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h vendor/lldb/dist/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h vendor/lldb/dist/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp vendor/lldb/dist/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp vendor/lldb/dist/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp vendor/lldb/dist/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp vendor/lldb/dist/source/Plugins/Process/FreeBSD/ProcessMonitor.h vendor/lldb/dist/source/Plugins/Process/POSIX/POSIXThread.cpp vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextFreeBSD_i386.cpp vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextFreeBSD_x86_64.cpp vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextPOSIX.h vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextPOSIXProcessMonitor_x86.cpp vendor/lldb/dist/source/Plugins/Process/Utility/RegisterContextLLDB.cpp vendor/lldb/dist/source/Plugins/Process/Utility/RegisterContextLLDB.h vendor/lldb/dist/source/Plugins/Process/Utility/UnwindLLDB.cpp vendor/lldb/dist/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp vendor/lldb/dist/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp vendor/lldb/dist/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp vendor/lldb/dist/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp vendor/lldb/dist/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h vendor/lldb/dist/source/Symbol/VariableList.cpp vendor/lldb/dist/source/Target/Process.cpp vendor/lldb/dist/source/Target/Thread.cpp Modified: vendor/lldb/dist/include/lldb/Core/ArchSpec.h ============================================================================== --- vendor/lldb/dist/include/lldb/Core/ArchSpec.h Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/include/lldb/Core/ArchSpec.h Tue Feb 25 21:42:16 2014 (r262497) @@ -92,6 +92,10 @@ public: eCore_x86_64_x86_64, eCore_x86_64_x86_64h, // Haswell enabled x86_64 + eCore_hexagon_generic, + eCore_hexagon_hexagonv4, + eCore_hexagon_hexagonv5, + eCore_uknownMach32, eCore_uknownMach64, kNumCores, @@ -103,6 +107,7 @@ public: kCore_ppc_any, kCore_ppc64_any, kCore_x86_32_any, + kCore_hexagon_any, kCore_arm_first = eCore_arm_generic, kCore_arm_last = eCore_arm_xscale, @@ -117,7 +122,10 @@ public: kCore_ppc64_last = eCore_ppc64_ppc970_64, kCore_x86_32_first = eCore_x86_32_i386, - kCore_x86_32_last = eCore_x86_32_i486sx + kCore_x86_32_last = eCore_x86_32_i486sx, + + kCore_hexagon_first = eCore_hexagon_generic, + kCore_hexagon_last = eCore_hexagon_hexagonv5 }; //------------------------------------------------------------------ Modified: vendor/lldb/dist/include/lldb/Core/IOHandler.h ============================================================================== --- vendor/lldb/dist/include/lldb/Core/IOHandler.h Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/include/lldb/Core/IOHandler.h Tue Feb 25 21:42:16 2014 (r262497) @@ -63,6 +63,16 @@ namespace lldb_private { virtual void Refresh () = 0; + // Called when an input reader should relinquish its control so another + // can be pushed onto the IO handler stack, or so the current IO + // handler can pop itself off the stack + + virtual void + Cancel () = 0; + + // Called when CTRL+C is pressed which usually causes + // Debugger::DispatchInputInterrupt to be called. + virtual void Interrupt () = 0; @@ -395,6 +405,9 @@ namespace lldb_private { Refresh (); virtual void + Cancel (); + + virtual void Interrupt (); virtual void @@ -500,7 +513,10 @@ namespace lldb_private { virtual void Refresh (); - + + virtual void + Cancel (); + virtual void Interrupt (); Modified: vendor/lldb/dist/include/lldb/Host/HostGetOpt.h ============================================================================== --- vendor/lldb/dist/include/lldb/Host/HostGetOpt.h Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/include/lldb/Host/HostGetOpt.h Tue Feb 25 21:42:16 2014 (r262497) @@ -17,4 +17,4 @@ #include -#endif \ No newline at end of file +#endif Modified: vendor/lldb/dist/include/lldb/Interpreter/PythonDataObjects.h ============================================================================== --- vendor/lldb/dist/include/lldb/Interpreter/PythonDataObjects.h Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/include/lldb/Interpreter/PythonDataObjects.h Tue Feb 25 21:42:16 2014 (r262497) @@ -98,6 +98,9 @@ namespace lldb_private { return m_py_obj != NULL; } + bool + IsNULLOrNone () const; + protected: PyObject* m_py_obj; }; Modified: vendor/lldb/dist/include/lldb/Symbol/VariableList.h ============================================================================== --- vendor/lldb/dist/include/lldb/Symbol/VariableList.h Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/include/lldb/Symbol/VariableList.h Tue Feb 25 21:42:16 2014 (r262497) @@ -49,10 +49,16 @@ public: lldb::VariableSP FindVariable (const ConstString& name); + + lldb::VariableSP + FindVariable (const ConstString& name, lldb::ValueType value_type); uint32_t FindVariableIndex (const lldb::VariableSP &var_sp); - + + size_t + AppendVariablesIfUnique(VariableList &var_list); + // Returns the actual number of unique variables that were added to the // list. "total_matches" will get updated with the actualy number of // matches that were found regardless of whether they were unique or not Modified: vendor/lldb/dist/include/lldb/Target/Process.h ============================================================================== --- vendor/lldb/dist/include/lldb/Target/Process.h Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/include/lldb/Target/Process.h Tue Feb 25 21:42:16 2014 (r262497) @@ -815,9 +815,16 @@ public: return m_monitor_callback_baton; } + // If the LaunchInfo has a monitor callback, then arrange to monitor the process. + // Return true if the LaunchInfo has taken care of monitoring the process, and false if the + // caller might want to monitor the process themselves. + bool MonitorProcess () const { + if (GetFlags().Test(lldb::eLaunchFlagsDontMonitorProcess)) + return true; + if (m_monitor_callback && ProcessIDIsValid()) { Host::StartMonitoringChildProcess (m_monitor_callback, Modified: vendor/lldb/dist/include/lldb/lldb-enumerations.h ============================================================================== --- vendor/lldb/dist/include/lldb/lldb-enumerations.h Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/include/lldb/lldb-enumerations.h Tue Feb 25 21:42:16 2014 (r262497) @@ -46,7 +46,9 @@ namespace lldb { eLaunchFlagDisableSTDIO = (1u << 4), ///< Disable stdio for inferior process (e.g. for a GUI app) eLaunchFlagLaunchInTTY = (1u << 5), ///< Launch the process in a new TTY if supported by the host eLaunchFlagLaunchInShell= (1u << 6), ///< Launch the process inside a shell to get shell expansion - eLaunchFlagLaunchInSeparateProcessGroup = (1u << 7) ///< Launch the process in a separate process group + eLaunchFlagLaunchInSeparateProcessGroup = (1u << 7), ///< Launch the process in a separate process group + eLaunchFlagsDontMonitorProcess = (1u << 8) ///< If you are going to hand the process off (e.g. to debugserver) + ///< set this flag so lldb & the handee don't race to reap it. } LaunchFlags; //---------------------------------------------------------------------- Modified: vendor/lldb/dist/source/API/SBFrame.cpp ============================================================================== --- vendor/lldb/dist/source/API/SBFrame.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/API/SBFrame.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -845,6 +845,8 @@ SBFrame::FindValue (const char *name, Va frame = exe_ctx.GetFramePtr(); if (frame) { + VariableList variable_list; + switch (value_type) { case eValueTypeVariableGlobal: // global variable @@ -852,8 +854,7 @@ SBFrame::FindValue (const char *name, Va case eValueTypeVariableArgument: // function argument variables case eValueTypeVariableLocal: // function local variables { - VariableList *variable_list = frame->GetVariableList(true); - + SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock)); const bool can_create = true; @@ -863,21 +864,22 @@ SBFrame::FindValue (const char *name, Va if (sc.block && sc.block->AppendVariables (can_create, get_parent_variables, stop_if_block_is_inlined_function, - variable_list)) + &variable_list)) { + if (value_type == eValueTypeVariableGlobal) + { + const bool get_file_globals = true; + VariableList* frame_vars = frame->GetVariableList(get_file_globals); + if (frame_vars) + frame_vars->AppendVariablesIfUnique(variable_list); + } ConstString const_name(name); - const uint32_t num_variables = variable_list->GetSize(); - for (uint32_t i = 0; i < num_variables; ++i) + VariableSP variable_sp(variable_list.FindVariable(const_name,value_type)); + if (variable_sp) { - VariableSP variable_sp (variable_list->GetVariableAtIndex(i)); - if (variable_sp && - variable_sp->GetScope() == value_type && - variable_sp->GetName() == const_name) - { - value_sp = frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues); - sb_value.SetSP (value_sp, use_dynamic); - break; - } + value_sp = frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues); + sb_value.SetSP (value_sp, use_dynamic); + break; } } } Modified: vendor/lldb/dist/source/Core/ArchSpec.cpp ============================================================================== --- vendor/lldb/dist/source/Core/ArchSpec.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Core/ArchSpec.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -105,6 +105,10 @@ static const CoreDefinition g_core_defin { eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , ArchSpec::eCore_x86_64_x86_64 , "x86_64" }, { eByteOrderLittle, 8, 1, 15, llvm::Triple::x86_64 , ArchSpec::eCore_x86_64_x86_64h , "x86_64h" }, + { eByteOrderLittle, 4, 4, 4, llvm::Triple::hexagon , ArchSpec::eCore_hexagon_generic, "hexagon" }, + { eByteOrderLittle, 4, 4, 4, llvm::Triple::hexagon , ArchSpec::eCore_hexagon_hexagonv4, "hexagonv4" }, + { eByteOrderLittle, 4, 4, 4, llvm::Triple::hexagon , ArchSpec::eCore_hexagon_hexagonv5, "hexagonv5" }, + { eByteOrderLittle, 4, 4, 4 , llvm::Triple::UnknownArch , ArchSpec::eCore_uknownMach32 , "unknown-mach-32" }, { eByteOrderLittle, 8, 4, 4 , llvm::Triple::UnknownArch , ArchSpec::eCore_uknownMach64 , "unknown-mach-64" } }; @@ -237,7 +241,8 @@ static const ArchDefinitionEntry g_elf_a { ArchSpec::eCore_arm_generic , llvm::ELF::EM_ARM , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // ARM { ArchSpec::eCore_sparc9_generic , llvm::ELF::EM_SPARCV9, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // SPARC V9 { ArchSpec::eCore_x86_64_x86_64 , llvm::ELF::EM_X86_64 , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // AMD64 - { ArchSpec::eCore_mips64 , llvm::ELF::EM_MIPS , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu } // MIPS + { ArchSpec::eCore_mips64 , llvm::ELF::EM_MIPS , LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu }, // MIPS + { ArchSpec::eCore_hexagon_generic , llvm::ELF::EM_HEXAGON, LLDB_INVALID_CPUTYPE, 0xFFFFFFFFu, 0xFFFFFFFFu } // HEXAGON }; static const ArchDefinition g_elf_arch_def = { @@ -919,6 +924,10 @@ cores_match (const ArchSpec::Core core1, if (core2 == ArchSpec::eCore_arm_armv7) return true; } + + case ArchSpec::kCore_hexagon_any: + if ((core2 >= ArchSpec::kCore_hexagon_first && core2 <= ArchSpec::kCore_hexagon_last) || (core2 == ArchSpec::kCore_hexagon_any)) + return true; break; case ArchSpec::eCore_arm_armv7m: Modified: vendor/lldb/dist/source/Core/Debugger.cpp ============================================================================== --- vendor/lldb/dist/source/Core/Debugger.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Core/Debugger.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -846,7 +846,7 @@ Debugger::ClearIOHandlers () { m_input_reader_stack.Pop(); reader_sp->SetIsDone(true); - reader_sp->Interrupt(); + reader_sp->Cancel(); } } } Modified: vendor/lldb/dist/source/Core/IOHandler.cpp ============================================================================== --- vendor/lldb/dist/source/Core/IOHandler.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Core/IOHandler.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -588,6 +588,13 @@ IOHandlerEditline::Refresh () } void +IOHandlerEditline::Cancel () +{ + if (m_editline_ap) + m_editline_ap->Interrupt (); +} + +void IOHandlerEditline::Interrupt () { if (m_editline_ap) @@ -5279,6 +5286,10 @@ IOHandlerCursesGUI::Refresh () { } +void +IOHandlerCursesGUI::Cancel () +{ +} void IOHandlerCursesGUI::Interrupt () Modified: vendor/lldb/dist/source/Expression/ClangExpressionDeclMap.cpp ============================================================================== --- vendor/lldb/dist/source/Expression/ClangExpressionDeclMap.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Expression/ClangExpressionDeclMap.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -1428,6 +1428,10 @@ ClangExpressionDeclMap::FindExternalVisi if (data_symbol) { + std::string warning("got name from symbols: "); + warning.append(name.AsCString()); + const unsigned diag_id = m_ast_context->getDiagnostics().getCustomDiagID(clang::DiagnosticsEngine::Level::Warning, "%0"); + m_ast_context->getDiagnostics().Report(diag_id) << warning.c_str(); AddOneGenericVariable(context, *data_symbol, current_id); context.m_found.variable = true; } Modified: vendor/lldb/dist/source/Host/common/Host.cpp ============================================================================== --- vendor/lldb/dist/source/Host/common/Host.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Host/common/Host.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -1743,25 +1743,32 @@ Host::LaunchProcessPosixSpawn (const cha // posix_spawnattr_setbinpref_np appears to be an Apple extension per: // http://www.unix.com/man-page/OSX/3/posix_spawnattr_setbinpref_np/ #if defined (__APPLE__) && !defined (__arm__) + + // Don't set the binpref if a shell was provided. After all, that's only going to affect what version of the shell + // is launched, not what fork of the binary is launched. We insert "arch --arch as part of the shell invocation + // to do that job on OSX. + + if (launch_info.GetShell() == nullptr) + { + // We don't need to do this for ARM, and we really shouldn't now that we + // have multiple CPU subtypes and no posix_spawnattr call that allows us + // to set which CPU subtype to launch... + const ArchSpec &arch_spec = launch_info.GetArchitecture(); + cpu_type_t cpu = arch_spec.GetMachOCPUType(); + cpu_type_t sub = arch_spec.GetMachOCPUSubType(); + if (cpu != 0 && + cpu != UINT32_MAX && + cpu != LLDB_INVALID_CPUTYPE && + !(cpu == 0x01000007 && sub == 8)) // If haswell is specified, don't try to set the CPU type or we will fail + { + size_t ocount = 0; + error.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX); + if (error.Fail() || log) + error.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %llu )", cpu, (uint64_t)ocount); - // We don't need to do this for ARM, and we really shouldn't now that we - // have multiple CPU subtypes and no posix_spawnattr call that allows us - // to set which CPU subtype to launch... - const ArchSpec &arch_spec = launch_info.GetArchitecture(); - cpu_type_t cpu = arch_spec.GetMachOCPUType(); - cpu_type_t sub = arch_spec.GetMachOCPUSubType(); - if (cpu != 0 && - cpu != UINT32_MAX && - cpu != LLDB_INVALID_CPUTYPE && - !(cpu == 0x01000007 && sub == 8)) // If haswell is specified, don't try to set the CPU type or we will fail - { - size_t ocount = 0; - error.SetError( ::posix_spawnattr_setbinpref_np (&attr, 1, &cpu, &ocount), eErrorTypePOSIX); - if (error.Fail() || log) - error.PutToLog(log, "::posix_spawnattr_setbinpref_np ( &attr, 1, cpu_type = 0x%8.8x, count => %llu )", cpu, (uint64_t)ocount); - - if (error.Fail() || ocount != 1) - return error; + if (error.Fail() || ocount != 1) + return error; + } } #endif Modified: vendor/lldb/dist/source/Interpreter/PythonDataObjects.cpp ============================================================================== --- vendor/lldb/dist/source/Interpreter/PythonDataObjects.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Interpreter/PythonDataObjects.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -84,6 +84,12 @@ PythonObject::Str () return PythonString(str); } +bool +PythonObject::IsNULLOrNone () const +{ + return ((m_py_obj == nullptr) || (m_py_obj == Py_None)); +} + //---------------------------------------------------------------------- // PythonString //---------------------------------------------------------------------- Modified: vendor/lldb/dist/source/Interpreter/ScriptInterpreterPython.cpp ============================================================================== --- vendor/lldb/dist/source/Interpreter/ScriptInterpreterPython.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Interpreter/ScriptInterpreterPython.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -781,7 +781,13 @@ public: { } - + + virtual void + Cancel () + { + + } + virtual void Interrupt () { @@ -2278,7 +2284,6 @@ ScriptInterpreterPython::LoadScriptingMo command_stream.Clear(); command_stream.Printf("sys.modules.__contains__('%s')",basename.c_str()); bool does_contain = false; - int refcount = 0; // this call will succeed if the module was ever imported in any Debugger in the lifetime of the process // in which this LLDB framework is living bool was_imported_globally = (ExecuteOneLineWithReturn(command_stream.GetData(), @@ -2288,10 +2293,7 @@ ScriptInterpreterPython::LoadScriptingMo // this call will fail if the module was not imported in this Debugger before command_stream.Clear(); command_stream.Printf("sys.getrefcount(%s)",basename.c_str()); - bool was_imported_locally = (ExecuteOneLineWithReturn(command_stream.GetData(), - ScriptInterpreterPython::eScriptReturnTypeInt, - &refcount, - ScriptInterpreter::ExecuteScriptOptions().SetEnableIO(false).SetSetLLDBGlobals(false)) && refcount > 0); + bool was_imported_locally = !(GetSessionDictionary().GetItemForKey(basename.c_str()).IsNULLOrNone()); bool was_imported = (was_imported_globally || was_imported_locally); @@ -2546,8 +2548,8 @@ ScriptInterpreterPython::InitializePriva Py_InitializeEx (0); // Initialize SWIG after setting up python - assert (g_swig_init_callback != NULL); - g_swig_init_callback (); + if (g_swig_init_callback) + g_swig_init_callback (); // Update the path python uses to search for modules to include the current directory. Modified: vendor/lldb/dist/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp ============================================================================== --- vendor/lldb/dist/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -235,22 +235,12 @@ ABIMacOSX_i386::GetRedZoneSize () const ABISP ABIMacOSX_i386::CreateInstance (const ArchSpec &arch) { - static ABISP g_abi_mac_sp; - static ABISP g_abi_other_sp; - if (arch.GetTriple().getArch() == llvm::Triple::x86) - { - if (arch.GetTriple().isOSDarwin()) - { - if (!g_abi_mac_sp) - g_abi_mac_sp.reset (new ABIMacOSX_i386(true)); - return g_abi_mac_sp; - } - else - { - if (!g_abi_other_sp) - g_abi_other_sp.reset (new ABIMacOSX_i386(false)); - return g_abi_other_sp; - } + static ABISP g_abi_sp; + if (arch.GetTriple().getArch() == llvm::Triple::x86) + { + if (!g_abi_sp) + g_abi_sp.reset (new ABIMacOSX_i386); + return g_abi_sp; } return ABISP(); } Modified: vendor/lldb/dist/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h ============================================================================== --- vendor/lldb/dist/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.h Tue Feb 25 21:42:16 2014 (r262497) @@ -71,24 +71,25 @@ public: return true; } + // The Darwin i386 ABI requires that stack frames be 16 byte aligned. + // When there is a trap handler on the stack, e.g. _sigtramp in userland + // code, we've seen that the stack pointer is often not aligned properly + // before the handler is invoked. This means that lldb will stop the unwind + // early -- before the function which caused the trap. + // + // To work around this, we relax that alignment to be just word-size (4-bytes). + // Whitelisting the trap handlers for user space would be easy (_sigtramp) but + // in other environments there can be a large number of different functions + // involved in async traps. + // + // If we were to enforce 16-byte alignment, we also need to relax to 4-byte + // alignment for non-darwin i386 targets. virtual bool CallFrameAddressIsValid (lldb::addr_t cfa) { - // Darwin call frame addresses must be 16-byte aligned, but other OS's - // only need 4-byte alignment. Otherwise the ABI matches, so we have - // this one minor override here. - if (target_is_darwin) - { - // Make sure the stack call frame addresses are are 16 byte aligned - if (cfa & (16ull - 1ull)) - return false; // Not 16 byte aligned - } - else - { - // Make sure the stack call frame addresses are are 4 byte aligned - if (cfa & (4ull - 1ull)) - return false; // Not 4 byte aligned - } + // Make sure the stack call frame addresses are are 4 byte aligned + if (cfa & (4ull - 1ull)) + return false; // Not 4 byte aligned if (cfa == 0) return false; // Zero is not a valid stack address return true; @@ -139,11 +140,7 @@ protected: RegisterIsCalleeSaved (const lldb_private::RegisterInfo *reg_info); private: - ABIMacOSX_i386(bool is_darwin) : lldb_private::ABI(), - target_is_darwin(is_darwin) - { } // Call CreateInstance instead. - - bool target_is_darwin; + ABIMacOSX_i386() : lldb_private::ABI() { } // Call CreateInstance instead. }; Modified: vendor/lldb/dist/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h ============================================================================== --- vendor/lldb/dist/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.h Tue Feb 25 21:42:16 2014 (r262497) @@ -68,12 +68,22 @@ public: return true; } + // The SysV x86_64 ABI requires that stack frames be 16 byte aligned. + // When there is a trap handler on the stack, e.g. _sigtramp in userland + // code, we've seen that the stack pointer is often not aligned properly + // before the handler is invoked. This means that lldb will stop the unwind + // early -- before the function which caused the trap. + // + // To work around this, we relax that alignment to be just word-size (8-bytes). + // Whitelisting the trap handlers for user space would be easy (_sigtramp) but + // in other environments there can be a large number of different functions + // involved in async traps. virtual bool CallFrameAddressIsValid (lldb::addr_t cfa) { - // Make sure the stack call frame addresses are 16 byte aligned - if (cfa & (16ull - 1ull)) - return false; // Not 16 byte aligned + // Make sure the stack call frame addresses are 8 byte aligned + if (cfa & (8ull - 1ull)) + return false; // Not 8 byte aligned if (cfa == 0) return false; // Zero is not a valid stack address return true; Modified: vendor/lldb/dist/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp ============================================================================== --- vendor/lldb/dist/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -468,7 +468,6 @@ ObjectFileELF::SetLoadAddress (Target &t lldb::addr_t value, bool value_is_offset) { - bool changed = false; ModuleSP module_sp = GetModule(); if (module_sp) { @@ -480,7 +479,7 @@ ObjectFileELF::SetLoadAddress (Target &t { const size_t num_sections = section_list->GetSize(); size_t sect_idx = 0; - + for (sect_idx = 0; sect_idx < num_sections; ++sect_idx) { // Iterate through the object file sections to find all @@ -493,7 +492,6 @@ ObjectFileELF::SetLoadAddress (Target &t ++num_loaded_sections; } } - changed = num_loaded_sections > 0; return num_loaded_sections > 0; } else @@ -503,7 +501,7 @@ ObjectFileELF::SetLoadAddress (Target &t } } } - return changed; + return false; // If it changed } ByteOrder Modified: vendor/lldb/dist/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp ============================================================================== --- vendor/lldb/dist/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -265,9 +265,6 @@ PlatformRemoteGDBServer::ConnectRemote ( // If a working directory was set prior to connecting, send it down now if (m_working_dir) m_gdb_client.SetWorkingDir(m_working_dir.GetCString()); -#if 0 - m_gdb_client.TestPacketSpeed(10000); -#endif } else { Modified: vendor/lldb/dist/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp ============================================================================== --- vendor/lldb/dist/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -132,6 +132,8 @@ ProcessFreeBSD::DoDetach(bool keep_stopp return error; } + DisableAllBreakpointSites(); + error = m_monitor->Detach(GetID()); if (error.Success()) Modified: vendor/lldb/dist/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp ============================================================================== --- vendor/lldb/dist/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -101,8 +101,8 @@ PtraceWrapper(int req, lldb::pid_t pid, log->Printf("ptrace() failed; errno=%d (%s)", errno, str); } -#ifdef __amd64__ if (log) { +#ifdef __amd64__ if (req == PT_GETREGS) { struct reg *r = (struct reg *) addr; @@ -111,8 +111,15 @@ PtraceWrapper(int req, lldb::pid_t pid, log->Printf("PT_GETREGS: bp=0x%lx", r->r_rbp); log->Printf("PT_GETREGS: ax=0x%lx", r->r_rax); } - } #endif + if (req == PT_GETDBREGS || req == PT_SETDBREGS) { + struct dbreg *r = (struct dbreg *) addr; + char setget = (req == PT_GETDBREGS) ? 'G' : 'S'; + + for (int i = 0; i <= 7; i++) + log->Printf("PT_%cETDBREGS: dr[%d]=0x%lx", setget, i, r->dr[i]); + } + } return result; } @@ -348,6 +355,82 @@ WriteRegOperation::Execute(ProcessMonito } //------------------------------------------------------------------------------ +/// @class ReadDebugRegOperation +/// @brief Implements ProcessMonitor::ReadDebugRegisterValue. +class ReadDebugRegOperation : public Operation +{ +public: + ReadDebugRegOperation(lldb::tid_t tid, unsigned offset, unsigned size, + RegisterValue &value, bool &result) + : m_tid(tid), m_offset(offset), m_size(size), + m_value(value), m_result(result) + { } + + void Execute(ProcessMonitor *monitor); + +private: + lldb::tid_t m_tid; + unsigned m_offset; + unsigned m_size; + RegisterValue &m_value; + bool &m_result; +}; + +void +ReadDebugRegOperation::Execute(ProcessMonitor *monitor) +{ + struct dbreg regs; + int rc; + + if ((rc = PTRACE(PT_GETDBREGS, m_tid, (caddr_t)®s, 0)) < 0) { + m_result = false; + } else { + if (m_size == sizeof(uintptr_t)) + m_value = *(uintptr_t *)(((caddr_t)®s) + m_offset); + else + memcpy(&m_value, (((caddr_t)®s) + m_offset), m_size); + m_result = true; + } +} + +//------------------------------------------------------------------------------ +/// @class WriteDebugRegOperation +/// @brief Implements ProcessMonitor::WriteDebugRegisterValue. +class WriteDebugRegOperation : public Operation +{ +public: + WriteDebugRegOperation(lldb::tid_t tid, unsigned offset, + const RegisterValue &value, bool &result) + : m_tid(tid), m_offset(offset), + m_value(value), m_result(result) + { } + + void Execute(ProcessMonitor *monitor); + +private: + lldb::tid_t m_tid; + unsigned m_offset; + const RegisterValue &m_value; + bool &m_result; +}; + +void +WriteDebugRegOperation::Execute(ProcessMonitor *monitor) +{ + struct dbreg regs; + + if (PTRACE(PT_GETDBREGS, m_tid, (caddr_t)®s, 0) < 0) { + m_result = false; + return; + } + *(uintptr_t *)(((caddr_t)®s) + m_offset) = (uintptr_t)m_value.GetAsUInt64(); + if (PTRACE(PT_SETDBREGS, m_tid, (caddr_t)®s, 0) < 0) + m_result = false; + else + m_result = true; +} + +//------------------------------------------------------------------------------ /// @class ReadGPROperation /// @brief Implements ProcessMonitor::ReadGPR. class ReadGPROperation : public Operation @@ -1175,7 +1258,7 @@ ProcessMonitor::MonitorSIGTRAP(ProcessMo case 0: case TRAP_TRACE: if (log) - log->Printf ("ProcessMonitor::%s() received trace event, tid = %" PRIu64, __FUNCTION__, tid); + log->Printf ("ProcessMonitor::%s() received trace event, tid = %" PRIu64 " : si_code = %d", __FUNCTION__, tid, info->si_code); message = ProcessMessage::Trace(tid); break; @@ -1464,6 +1547,28 @@ ProcessMonitor::WriteRegisterValue(lldb: } bool +ProcessMonitor::ReadDebugRegisterValue(lldb::tid_t tid, unsigned offset, + const char *reg_name, unsigned size, + lldb_private::RegisterValue &value) +{ + bool result; + ReadDebugRegOperation op(tid, offset, size, value, result); + DoOperation(&op); + return result; +} + +bool +ProcessMonitor::WriteDebugRegisterValue(lldb::tid_t tid, unsigned offset, + const char *reg_name, + const lldb_private::RegisterValue &value) +{ + bool result; + WriteDebugRegOperation op(tid, offset, value, result); + DoOperation(&op); + return result; +} + +bool ProcessMonitor::ReadGPR(lldb::tid_t tid, void *buf, size_t buf_size) { bool result; Modified: vendor/lldb/dist/source/Plugins/Process/FreeBSD/ProcessMonitor.h ============================================================================== --- vendor/lldb/dist/source/Plugins/Process/FreeBSD/ProcessMonitor.h Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Plugins/Process/FreeBSD/ProcessMonitor.h Tue Feb 25 21:42:16 2014 (r262497) @@ -116,6 +116,23 @@ public: WriteRegisterValue(lldb::tid_t tid, unsigned offset, const char *reg_name, const lldb_private::RegisterValue &value); + /// Reads the contents from the debug register identified by the given + /// (architecture dependent) offset. + /// + /// This method is provided for use by RegisterContextFreeBSD derivatives. + bool + ReadDebugRegisterValue(lldb::tid_t tid, unsigned offset, + const char *reg_name, unsigned size, + lldb_private::RegisterValue &value); + + /// Writes the given value to the debug register identified by the given + /// (architecture dependent) offset. + /// + /// This method is provided for use by RegisterContextFreeBSD derivatives. + bool + WriteDebugRegisterValue(lldb::tid_t tid, unsigned offset, + const char *reg_name, + const lldb_private::RegisterValue &value); /// Reads all general purpose registers into the specified buffer. bool ReadGPR(lldb::tid_t tid, void *buf, size_t buf_size); Modified: vendor/lldb/dist/source/Plugins/Process/POSIX/POSIXThread.cpp ============================================================================== --- vendor/lldb/dist/source/Plugins/Process/POSIX/POSIXThread.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Plugins/Process/POSIX/POSIXThread.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -65,7 +65,16 @@ POSIXThread::POSIXThread(Process &proces lldb::WatchpointSP wp = wp_list.GetByIndex(wp_idx); if (wp.get() && wp->IsEnabled()) { - assert(EnableHardwareWatchpoint(wp.get())); + // This watchpoint as been enabled; obviously this "new" thread + // has been created since that watchpoint was enabled. Since + // the POSIXBreakpointProtocol has yet to be initialized, its + // m_watchpoints_initialized member will be FALSE. Attempting to + // read the debug status register to determine if a watchpoint + // has been hit would result in the zeroing of that register. + // Since the active debug registers would have been cloned when + // this thread was created, simply force the m_watchpoints_initized + // member to TRUE and avoid resetting dr6 and dr7. + GetPOSIXBreakpointProtocol()->ForceWatchpointsInitialized(); } } } @@ -509,6 +518,21 @@ POSIXThread::WatchNotify(const ProcessMe void POSIXThread::TraceNotify(const ProcessMessage &message) { + POSIXBreakpointProtocol* reg_ctx = GetPOSIXBreakpointProtocol(); + if (reg_ctx) + { + uint32_t num_hw_wps = reg_ctx->NumSupportedHardwareWatchpoints(); + uint32_t wp_idx; + for (wp_idx = 0; wp_idx < num_hw_wps; wp_idx++) + { + if (reg_ctx->IsWatchpointHit(wp_idx)) + { + WatchNotify(message); + return; + } + } + } + SetStopInfo (StopInfo::CreateStopReasonToTrace(*this)); } Modified: vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextFreeBSD_i386.cpp ============================================================================== --- vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextFreeBSD_i386.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextFreeBSD_i386.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -37,8 +37,18 @@ struct GPR uint32_t gs; }; -#define DR_SIZE 0 -#define DR_OFFSET(reg_index) 0 +struct dbreg { + uint32_t dr[8]; /* debug registers */ + /* Index 0-3: debug address registers */ + /* Index 4-5: reserved */ + /* Index 6: debug status */ + /* Index 7: debug control */ +}; + + +#define DR_SIZE sizeof(uint32_t) +#define DR_OFFSET(reg_index) \ + (LLVM_EXTENSION offsetof(dbreg, dr[reg_index])) //--------------------------------------------------------------------------- // Include RegisterInfos_i386 to declare our g_register_infos_i386 structure. Modified: vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextFreeBSD_x86_64.cpp ============================================================================== --- vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextFreeBSD_x86_64.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextFreeBSD_x86_64.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -46,8 +46,19 @@ typedef struct _GPR uint64_t ss; } GPR; -#define DR_SIZE 0 -#define DR_OFFSET(reg_index) 0 +struct dbreg { + uint64_t dr[16]; /* debug registers */ + /* Index 0-3: debug address registers */ + /* Index 4-5: reserved */ + /* Index 6: debug status */ + /* Index 7: debug control */ + /* Index 8-15: reserved */ +}; + +#define DR_SIZE sizeof(uint64_t) +#define DR_OFFSET(reg_index) \ + (LLVM_EXTENSION offsetof(dbreg, dr[reg_index])) + //--------------------------------------------------------------------------- // Include RegisterInfos_x86_64 to declare our g_register_infos_x86_64 structure. Modified: vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextPOSIX.h ============================================================================== --- vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextPOSIX.h Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextPOSIX.h Tue Feb 25 21:42:16 2014 (r262497) @@ -66,6 +66,10 @@ public: virtual uint32_t NumSupportedHardwareWatchpoints () = 0; + // Force m_watchpoints_initialized to TRUE + void + ForceWatchpointsInitialized () {m_watchpoints_initialized = true;} + protected: bool m_watchpoints_initialized; }; Modified: vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextPOSIXProcessMonitor_x86.cpp ============================================================================== --- vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextPOSIXProcessMonitor_x86.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Plugins/Process/POSIX/RegisterContextPOSIXProcessMonitor_x86.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -109,6 +109,15 @@ RegisterContextPOSIXProcessMonitor_x86_6 RegisterValue &value) { ProcessMonitor &monitor = GetMonitor(); + +#if defined(__FreeBSD__) + if (reg >= m_reg_info.first_dr) + return monitor.ReadDebugRegisterValue(m_thread.GetID(), + GetRegisterOffset(reg), + GetRegisterName(reg), + GetRegisterSize(reg), + value); +#endif return monitor.ReadRegisterValue(m_thread.GetID(), GetRegisterOffset(reg), GetRegisterName(reg), @@ -164,6 +173,13 @@ RegisterContextPOSIXProcessMonitor_x86_6 } ProcessMonitor &monitor = GetMonitor(); +#if defined(__FreeBSD__) + if (reg >= m_reg_info.first_dr) + return monitor.WriteDebugRegisterValue(m_thread.GetID(), + GetRegisterOffset(reg_to_write), + GetRegisterName(reg_to_write), + value_to_write); +#endif return monitor.WriteRegisterValue(m_thread.GetID(), GetRegisterOffset(reg_to_write), GetRegisterName(reg_to_write), Modified: vendor/lldb/dist/source/Plugins/Process/Utility/RegisterContextLLDB.cpp ============================================================================== --- vendor/lldb/dist/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Tue Feb 25 21:35:15 2014 (r262496) +++ vendor/lldb/dist/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Tue Feb 25 21:42:16 2014 (r262497) @@ -50,6 +50,7 @@ RegisterContextLLDB::RegisterContextLLDB m_thread(thread), m_fast_unwind_plan_sp (), m_full_unwind_plan_sp (), + m_fallback_unwind_plan_sp (), m_all_registers_available(false), m_frame_type (-1), m_cfa (LLDB_INVALID_ADDRESS), @@ -764,8 +765,10 @@ RegisterContextLLDB::GetFullUnwindPlanFo { m_fast_unwind_plan_sp.reset(); unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtCallSite (m_current_offset_backed_up_one); - if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc)) + if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc) && unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolYes) + { return unwind_plan_sp; + } } // Ask the DynamicLoader if the eh_frame CFI should be trusted in this frame even when it's frame zero @@ -791,6 +794,15 @@ RegisterContextLLDB::GetFullUnwindPlanFo unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite (m_thread); if (unwind_plan_sp && unwind_plan_sp->PlanValidAtAddress (m_current_pc)) { + if (unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolNo) + { + // We probably have an UnwindPlan created by inspecting assembly instructions, and we probably + // don't have any eh_frame instructions available. + // The assembly profilers work really well with compiler-generated functions but hand-written + // assembly can be problematic. We'll set the architecture default UnwindPlan as our fallback + // UnwindPlan in case this doesn't work out when we try to unwind. + m_fallback_unwind_plan_sp = arch_default_unwind_plan_sp; + } UnwindLogMsgVerbose ("frame uses %s for full UnwindPlan", unwind_plan_sp->GetSourceName().GetCString()); return unwind_plan_sp; } @@ -808,6 +820,16 @@ RegisterContextLLDB::GetFullUnwindPlanFo // We'd prefer to use an UnwindPlan intended for call sites when we're at a call site but if we've // struck out on that, fall back to using the non-call-site assembly inspection UnwindPlan if possible. unwind_plan_sp = func_unwinders_sp->GetUnwindPlanAtNonCallSite (m_thread); + if (unwind_plan_sp->GetSourcedFromCompiler() == eLazyBoolNo) + { + // We probably have an UnwindPlan created by inspecting assembly instructions, and we probably + // don't have any eh_frame instructions available. + // The assembly profilers work really well with compiler-generated functions but hand-written + // assembly can be problematic. We'll set the architecture default UnwindPlan as our fallback + // UnwindPlan in case this doesn't work out when we try to unwind. + m_fallback_unwind_plan_sp = arch_default_unwind_plan_sp; + } + if (IsUnwindPlanValidForCurrentPC(unwind_plan_sp, valid_offset)) { UnwindLogMsgVerbose ("frame uses %s for full UnwindPlan", unwind_plan_sp->GetSourceName().GetCString()); @@ -1176,21 +1198,22 @@ RegisterContextLLDB::SavedLocationForReg m_full_unwind_plan_sp->GetSourceName().GetCString()); // Throw away the full unwindplan; install the arch default unwindplan - InvalidateFullUnwindPlan(); - - // Now re-fetch the pc value we're searching for - uint32_t arch_default_pc_reg = LLDB_INVALID_REGNUM; - UnwindPlan::RowSP active_row = m_full_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset); - if (m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, m_full_unwind_plan_sp->GetRegisterKind(), arch_default_pc_reg) - && arch_default_pc_reg != LLDB_INVALID_REGNUM - && active_row - && active_row->GetRegisterInfo (arch_default_pc_reg, unwindplan_regloc)) + if (TryFallbackUnwindPlan()) { - have_unwindplan_regloc = true; - } - else - { - have_unwindplan_regloc = false; + // Now re-fetch the pc value we're searching for + uint32_t arch_default_pc_reg = LLDB_INVALID_REGNUM; + UnwindPlan::RowSP active_row = m_full_unwind_plan_sp->GetRowForFunctionOffset (m_current_offset); + if (m_thread.GetRegisterContext()->ConvertBetweenRegisterKinds (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC, m_full_unwind_plan_sp->GetRegisterKind(), arch_default_pc_reg) + && arch_default_pc_reg != LLDB_INVALID_REGNUM + && active_row + && active_row->GetRegisterInfo (arch_default_pc_reg, unwindplan_regloc)) + { + have_unwindplan_regloc = true; + } + else + { + have_unwindplan_regloc = false; + } } } } @@ -1333,54 +1356,48 @@ RegisterContextLLDB::SavedLocationForReg } // If the Full unwindplan has been determined to be incorrect, this method will -// replace it with the architecture's default unwindplna, if one is defined. +// replace it with the architecture's default unwindplan, if one is defined. // It will also find the FuncUnwinders object for this function and replace the // Full unwind method for the function there so we don't use the errant Full unwindplan // again in the future of this debug session. // We're most likely doing this because the Full unwindplan was generated by assembly // instruction profiling and the profiler got something wrong. -void -RegisterContextLLDB::InvalidateFullUnwindPlan () +bool +RegisterContextLLDB::TryFallbackUnwindPlan () { UnwindPlan::Row::RegisterLocation unwindplan_regloc; - ExecutionContext exe_ctx (m_thread.shared_from_this()); - Process *process = exe_ctx.GetProcessPtr(); *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***