diff --git a/lldb/include/lldb/lldb-private-log.h b/lldb/include/lldb/lldb-private-log.h index 0c451d14695c..277cc9125c33 100644 --- a/lldb/include/lldb/lldb-private-log.h +++ b/lldb/include/lldb/lldb-private-log.h @@ -36,6 +36,7 @@ #define LIBLLDB_LOG_HOST (1u << 14) #define LIBLLDB_LOG_UNWIND (1u << 15) #define LIBLLDB_LOG_API (1u << 16) +#define LIBLLDB_LOG_DYNAMIC_LOADER (1u << 17) #define LIBLLDB_LOG_ALL (UINT32_MAX) #define LIBLLDB_LOG_DEFAULT (LIBLLDB_LOG_PROCESS |\ LIBLLDB_LOG_THREAD |\ diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 25f56c63e422..8b847a2848fb 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -195,7 +195,6 @@ 26D5B0F211B07550009A862E /* ThreadPlanStepThrough.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C847510F50EFC00BB2B04 /* ThreadPlanStepThrough.cpp */; }; 26D5B0F311B07550009A862E /* ThreadPlanStepRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C847610F50EFC00BB2B04 /* ThreadPlanStepRange.cpp */; }; 26D5B0F411B07550009A862E /* DynamicLoaderMacOSXDYLD.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C897A10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.cpp */; }; - 26D5B0F511B07550009A862E /* DynamicLoaderMacOSXDYLDLog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C897C10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLDLog.cpp */; }; 26D5B0F611B07550009A862E /* ObjectContainerUniversalMachO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C898010F57C5600BB2B04 /* ObjectContainerUniversalMachO.cpp */; }; 26D5B0F711B07550009A862E /* ObjectFileELF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C898510F57C5600BB2B04 /* ObjectFileELF.cpp */; }; 26D5B0F811B07550009A862E /* ObjectFileMachO.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 260C898810F57C5600BB2B04 /* ObjectFileMachO.cpp */; }; @@ -436,8 +435,6 @@ 260C897510F57C5600BB2B04 /* DisassemblerLLVM.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DisassemblerLLVM.h; sourceTree = ""; }; 260C897A10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicLoaderMacOSXDYLD.cpp; sourceTree = ""; }; 260C897B10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicLoaderMacOSXDYLD.h; sourceTree = ""; }; - 260C897C10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLDLog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicLoaderMacOSXDYLDLog.cpp; sourceTree = ""; }; - 260C897D10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLDLog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DynamicLoaderMacOSXDYLDLog.h; sourceTree = ""; }; 260C898010F57C5600BB2B04 /* ObjectContainerUniversalMachO.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectContainerUniversalMachO.cpp; sourceTree = ""; }; 260C898110F57C5600BB2B04 /* ObjectContainerUniversalMachO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectContainerUniversalMachO.h; sourceTree = ""; }; 260C898510F57C5600BB2B04 /* ObjectFileELF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectFileELF.cpp; sourceTree = ""; }; @@ -1237,8 +1234,6 @@ children = ( 260C897B10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.h */, 260C897A10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLD.cpp */, - 260C897D10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLDLog.h */, - 260C897C10F57C5600BB2B04 /* DynamicLoaderMacOSXDYLDLog.cpp */, ); path = "MacOSX-DYLD"; sourceTree = ""; @@ -2680,7 +2675,6 @@ 26D5B0F211B07550009A862E /* ThreadPlanStepThrough.cpp in Sources */, 26D5B0F311B07550009A862E /* ThreadPlanStepRange.cpp in Sources */, 26D5B0F411B07550009A862E /* DynamicLoaderMacOSXDYLD.cpp in Sources */, - 26D5B0F511B07550009A862E /* DynamicLoaderMacOSXDYLDLog.cpp in Sources */, 26D5B0F611B07550009A862E /* ObjectContainerUniversalMachO.cpp in Sources */, 26D5B0F711B07550009A862E /* ObjectFileELF.cpp in Sources */, 26D5B0F811B07550009A862E /* ObjectFileMachO.cpp in Sources */, diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp index 10e7e7a50346..fa46c77553aa 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -23,7 +23,6 @@ #include "lldb/Target/StackFrame.h" #include "DynamicLoaderMacOSXDYLD.h" -#include "DynamicLoaderMacOSXDYLDLog.h" //#define ENABLE_DEBUG_PRINTF // COMMENT THIS LINE OUT PRIOR TO CHECKIN #ifdef ENABLE_DEBUG_PRINTF @@ -501,6 +500,7 @@ DynamicLoaderMacOSXDYLD::ReadAllImageInfosStructure () uint32_t DynamicLoaderMacOSXDYLD::UpdateAllImageInfos() { + Log *log = lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_DYNAMIC_LOADER); if (ReadAllImageInfosStructure ()) { Mutex::Locker locker(m_mutex); @@ -566,18 +566,45 @@ DynamicLoaderMacOSXDYLD::UpdateAllImageInfos() if (m_dyld_image_infos.size() < old_dyld_all_image_infos.size()) { ModuleList unloaded_module_list; - for (idx = m_dyld_image_infos.size(); idx < old_dyld_all_image_infos.size(); ++idx) + uint32_t old_idx; + for (idx = 0; idx < old_dyld_all_image_infos.size(); ++idx) { - ModuleSP unload_image_module_sp(m_process->GetTarget().GetImages().FindFirstModuleForFileSpec (old_dyld_all_image_infos[idx].file_spec)); - if (unload_image_module_sp.get()) + for (old_idx = idx; old_idx < old_dyld_all_image_infos.size(); ++old_idx) { - if (UnloadImageLoadAddress (unload_image_module_sp.get(), old_dyld_all_image_infos[idx])) - unloaded_module_list.AppendInNeeded (unload_image_module_sp); + if (m_dyld_image_infos[idx].file_spec == old_dyld_all_image_infos[old_idx].file_spec) + { + old_dyld_all_image_infos[old_idx].address = LLDB_INVALID_ADDRESS; + break; + } } } + + if (log) + log->PutCString("Unloaded:"); + + for (old_idx = 0; old_idx < old_dyld_all_image_infos.size(); ++old_idx) + { + if (old_dyld_all_image_infos[old_idx].address != LLDB_INVALID_ADDRESS) + { + if (log) + old_dyld_all_image_infos[old_idx].PutToLog (log); + ModuleSP unload_image_module_sp(m_process->GetTarget().GetImages().FindFirstModuleForFileSpec (old_dyld_all_image_infos[old_idx].file_spec)); + if (unload_image_module_sp.get()) + { + if (UnloadImageLoadAddress (unload_image_module_sp.get(), old_dyld_all_image_infos[old_idx])) + unloaded_module_list.AppendInNeeded (unload_image_module_sp); + } + } + } + if (unloaded_module_list.GetSize() > 0) m_process->GetTarget().ModulesDidUnload (unloaded_module_list); } + else + { + if (log) + PutToLog(log); + } } else { @@ -640,7 +667,6 @@ DynamicLoaderMacOSXDYLD::UpdateAllImageInfos() } } } - PutToLog(DynamicLoaderMacOSXDYLDLog::GetLogIfAllCategoriesSet (1)); if (loaded_module_list.GetSize() > 0) { // FIXME: This should really be in the Runtime handlers class, which should get @@ -960,7 +986,7 @@ DynamicLoaderMacOSXDYLD::PutToLog(Log *log) const const size_t count = m_dyld_image_infos.size(); if (count > 0) { - log->Printf("\tdyld_image_infos"); + log->PutCString("Loaded:"); for (i = 0; iGetMask().SetAllFlagBits(0xffffffffu); -// g_log->GetOptions().Set(LLDB_LOG_OPTION_THREADSAFE | LLDB_LOG_OPTION_PREPEND_THREAD_NAME); -// } - } - else - { - if (g_log) - delete g_log; - g_log = log; - } - - return g_log; -} - -Log * -DynamicLoaderMacOSXDYLDLog::GetLogIfAllCategoriesSet (uint32_t mask) -{ - Log *log = LogAccessor (true, NULL); - if (log && mask) - { - uint32_t log_mask = log->GetMask().Get(); - if ((log_mask & mask) != mask) - return NULL; - } - return log; -} - -void -DynamicLoaderMacOSXDYLDLog::SetLog (Log *log) -{ - LogAccessor (false, log); -} - - -void -DynamicLoaderMacOSXDYLDLog::LogIf (uint32_t mask, const char *format, ...) -{ - Log *log = DynamicLoaderMacOSXDYLDLog::GetLogIfAllCategoriesSet (mask); - if (log) - { - va_list args; - va_start (args, format); - log->VAPrintf (format, args); - va_end (args); - } -} diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLDLog.h b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLDLog.h deleted file mode 100644 index 9282ba576471..000000000000 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLDLog.h +++ /dev/null @@ -1,34 +0,0 @@ -//===-- DynamicLoaderMacOSXDYLDLog.h ----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef liblldb_DynamicLoaderMacOSXDYLDLog_h_ -#define liblldb_DynamicLoaderMacOSXDYLDLog_h_ - -// C Includes -// C++ Includes -// Other libraries and framework includes - -#include "lldb/lldb-private.h" - -// Project includes - -class DynamicLoaderMacOSXDYLDLog -{ -public: - static lldb_private::Log * - GetLogIfAllCategoriesSet (uint32_t mask); - - static void - SetLog (lldb_private::Log *log); - - static void - LogIf (uint32_t mask, const char *format, ...); -}; - -#endif // liblldb_DynamicLoaderMacOSXDYLDLog_h_ diff --git a/lldb/source/lldb-log.cpp b/lldb/source/lldb-log.cpp index a7ba32801f16..dcda478281c8 100644 --- a/lldb/source/lldb-log.cpp +++ b/lldb/source/lldb-log.cpp @@ -124,6 +124,7 @@ lldb_private::DisableLog (Args &args, Stream *feedback_strm) else if (strcasecmp(arg, "api") == 0) flag_bits &= ~LIBLLDB_LOG_API; else if (strcasestr(arg, "break") == arg) flag_bits &= ~LIBLLDB_LOG_BREAKPOINTS; else if (strcasecmp(arg, "default") == 0 ) flag_bits &= ~LIBLLDB_LOG_DEFAULT; + else if (strcasecmp(arg, "dyld") == 0 ) flag_bits &= ~LIBLLDB_LOG_DYNAMIC_LOADER; else if (strcasestr(arg, "event") == arg) flag_bits &= ~LIBLLDB_LOG_EVENTS; else if (strcasestr(arg, "expr") == arg) flag_bits &= ~LIBLLDB_LOG_EXPRESSIONS; else if (strcasestr(arg, "object") == arg) flag_bits &= ~LIBLLDB_LOG_OBJECT; @@ -182,6 +183,7 @@ lldb_private::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, Args &ar else if (strcasecmp(arg, "api") == 0) flag_bits |= LIBLLDB_LOG_API; else if (strcasestr(arg, "break") == arg) flag_bits |= LIBLLDB_LOG_BREAKPOINTS; else if (strcasecmp(arg, "default") == 0 ) flag_bits |= LIBLLDB_LOG_DEFAULT; + else if (strcasecmp(arg, "dyld") == 0 ) flag_bits |= LIBLLDB_LOG_DYNAMIC_LOADER; else if (strcasestr(arg, "event") == arg) flag_bits |= LIBLLDB_LOG_EVENTS; else if (strcasestr(arg, "expr") == arg) flag_bits |= LIBLLDB_LOG_EXPRESSIONS; else if (strcasestr(arg, "object") == arg) flag_bits |= LIBLLDB_LOG_OBJECT;