Author: jingham Date: Thu Dec 6 17:18:40 2018 New Revision: 348559 URL: http://llvm.org/viewvc/llvm-project?rev=348559&view=rev Log: Handle detecting exec for DynamicLoaderMacOS with older debugservers that don't send reason:exec.
<rdar://problem/43756823> Differential Revision: https://reviews.llvm.org/D55399 Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp?rev=348559&r1=348558&r2=348559&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.cpp Thu Dec 6 17:18:40 2018 @@ -79,7 +79,8 @@ DynamicLoader *DynamicLoaderMacOS::Creat //---------------------------------------------------------------------- DynamicLoaderMacOS::DynamicLoaderMacOS(Process *process) : DynamicLoaderDarwin(process), m_image_infos_stop_id(UINT32_MAX), - m_break_id(LLDB_INVALID_BREAK_ID), m_mutex() {} + m_break_id(LLDB_INVALID_BREAK_ID), m_mutex(), + m_maybe_image_infos_address(LLDB_INVALID_ADDRESS) {} //---------------------------------------------------------------------- // Destructor @@ -95,16 +96,31 @@ bool DynamicLoaderMacOS::ProcessDidExec( if (m_process) { // If we are stopped after an exec, we will have only one thread... if (m_process->GetThreadList().GetSize() == 1) { - // See if we are stopped at '_dyld_start' - ThreadSP thread_sp(m_process->GetThreadList().GetThreadAtIndex(0)); - if (thread_sp) { - lldb::StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0)); - if (frame_sp) { - const Symbol *symbol = - frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol; - if (symbol) { - if (symbol->GetName() == ConstString("_dyld_start")) - did_exec = true; + // Maybe we still have an image infos address around? If so see + // if that has changed, and if so we have exec'ed. + if (m_maybe_image_infos_address != LLDB_INVALID_ADDRESS) { + lldb::addr_t image_infos_address = m_process->GetImageInfoAddress(); + if (image_infos_address != m_maybe_image_infos_address) { + // We don't really have to reset this here, since we are going to + // call DoInitialImageFetch right away to handle the exec. But in + // case anybody looks at it in the meantime, it can't hurt. + m_maybe_image_infos_address = image_infos_address; + did_exec = true; + } + } + + if (!did_exec) { + // See if we are stopped at '_dyld_start' + ThreadSP thread_sp(m_process->GetThreadList().GetThreadAtIndex(0)); + if (thread_sp) { + lldb::StackFrameSP frame_sp(thread_sp->GetStackFrameAtIndex(0)); + if (frame_sp) { + const Symbol *symbol = + frame_sp->GetSymbolContext(eSymbolContextSymbol).symbol; + if (symbol) { + if (symbol->GetName() == ConstString("_dyld_start")) + did_exec = true; + } } } } @@ -180,6 +196,7 @@ void DynamicLoaderMacOS::DoInitialImageF } m_dyld_image_infos_stop_id = m_process->GetStopID(); + m_maybe_image_infos_address = m_process->GetImageInfoAddress(); } bool DynamicLoaderMacOS::NeedToDoInitialImageFetch() { return true; } Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h?rev=348559&r1=348558&r2=348559&view=diff ============================================================================== --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h (original) +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h Thu Dec 6 17:18:40 2018 @@ -104,6 +104,12 @@ protected: // loaded/unloaded images lldb::user_id_t m_break_id; mutable std::recursive_mutex m_mutex; + lldb::addr_t m_maybe_image_infos_address; // If dyld is still maintaining the + // all_image_infos address, store it + // here so we can use it to detect + // exec's when talking to + // debugservers that don't support + // the "reason:exec" annotation. private: DISALLOW_COPY_AND_ASSIGN(DynamicLoaderMacOS); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits