diff options
| author | Enrico Granata <egranata@apple.com> | 2012-11-08 02:22:02 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2012-11-08 02:22:02 +0000 |
| commit | 1759848be00a5ab48ba5bccb70945b30c68da7f1 (patch) | |
| tree | 75c6491edf772cba8614f2d67be5681e9d98b5a3 /lldb/source/Plugins | |
| parent | 489b5d645f370926894c88d8e5fd27f17aabff82 (diff) | |
| download | bcm5719-llvm-1759848be00a5ab48ba5bccb70945b30c68da7f1.tar.gz bcm5719-llvm-1759848be00a5ab48ba5bccb70945b30c68da7f1.zip | |
<rdar://problem/12586350>
This commit does three things:
(a) introduces a new notification model for adding/removing/changing modules to a ModuleList, and applies it to the Target's ModuleList, so that we make sure to always trigger the right set of actions
whenever modules come and go in a target. Certain spots in the code still need to "manually" notify the Target for several reasons, so this is a work in progress
(b) adds a new capability to the Platforms: locating a scripting resources associated to a module. A scripting resource is a Python file that can load commands, formatters, ... and any other action
of interest corresponding to the loading of a module. At the moment, this is only implemented on Mac OS X and only for files inside .dSYM bundles - the next step is going to be letting
the frameworks themselves hold their scripting resources. Implementors of platforms for other systems are free to implement "the right thing" for their own worlds
(c) hooking up items (a) and (b) so that targets auto-load the scripting resources as the corresponding modules get loaded in a target. This has a few caveats at the moment:
- the user needs to manually add the .py file to the dSYM (soon, it will also work in the framework itself)
- if two modules with the same name show up during the lifetime of an LLDB session, the second one won't be able to load its scripting resource, but will otherwise work just fine
llvm-svn: 167569
Diffstat (limited to 'lldb/source/Plugins')
9 files changed, 55 insertions, 23 deletions
diff --git a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp index 3863762a276..194f21e0067 100644 --- a/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp +++ b/lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp @@ -281,7 +281,7 @@ DynamicLoaderDarwinKernel::OSKextLoadedKextSummary::LoadImageUsingMemoryModule ( { if (uuid_is_valid) { - ModuleList &target_images = target.GetImages(); + const ModuleList &target_images = target.GetImages(); module_sp = target_images.FindModule(uuid); if (!module_sp) @@ -669,10 +669,7 @@ DynamicLoaderDarwinKernel::AddModulesUsingImageInfos (OSKextLoadedKextSummary::c loaded_module_list.AppendIfNeeded (image_infos[idx].module_sp); } - if (loaded_module_list.GetSize() > 0) - { - m_process->GetTarget().ModulesDidLoad (loaded_module_list); - } + m_process->GetTarget().ModulesDidLoad (loaded_module_list); return true; } diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp index 1b9be627569..4723da8b184 100644 --- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp @@ -287,7 +287,9 @@ DynamicLoaderMacOSXDYLD::FindTargetModuleForDYLDImageInfo (const DYLDImageInfo & { if (did_create_ptr) *did_create_ptr = false; - ModuleList &target_images = m_process->GetTarget().GetImages(); + + + const ModuleList &target_images = m_process->GetTarget().GetImages(); ModuleSpec module_spec (image_info.file_spec, image_info.GetArchitecture ()); module_spec.GetUUID() = image_info.uuid; ModuleSP module_sp (target_images.FindFirstModule (module_spec)); @@ -816,7 +818,7 @@ DynamicLoaderMacOSXDYLD::AddModulesUsingImageInfos (DYLDImageInfo::collection &i Section *commpage_section = sections->FindSectionByName(commpage_dbstr).get(); if (commpage_section) { - ModuleList& target_images = m_process->GetTarget().GetImages(); + const ModuleList& target_images = m_process->GetTarget().GetImages(); ModuleSpec module_spec (objfile->GetFileSpec(), image_infos[idx].GetArchitecture ()); module_spec.GetObjectName() = commpage_dbstr; ModuleSP commpage_image_module_sp(target_images.FindFirstModule (module_spec)); @@ -966,7 +968,7 @@ DynamicLoaderMacOSXDYLD::RemoveModulesUsingImageInfosAddress (lldb::addr_t image log->PutCString("Unloaded:"); unloaded_module_list.LogUUIDAndPaths (log, "DynamicLoaderMacOSXDYLD::ModulesDidUnload"); } - m_process->GetTarget().ModulesDidUnload (unloaded_module_list); + m_process->GetTarget().GetImages().Remove (unloaded_module_list); } m_dyld_image_infos_stop_id = m_process->GetStopID(); return true; @@ -1060,7 +1062,7 @@ DynamicLoaderMacOSXDYLD::InitializeFromAllImageInfos () // to an equivalent version. We don't want it to stay in the target's module list or it will confuse // us, so unload it here. Target &target = m_process->GetTarget(); - ModuleList &target_modules = target.GetImages(); + const ModuleList &target_modules = target.GetImages(); ModuleList not_loaded_modules; Mutex::Locker modules_locker(target_modules.GetMutex()); @@ -1082,7 +1084,7 @@ DynamicLoaderMacOSXDYLD::InitializeFromAllImageInfos () if (not_loaded_modules.GetSize() != 0) { - target.ModulesDidUnload(not_loaded_modules); + target.GetImages().Remove(not_loaded_modules); } return true; @@ -1586,7 +1588,7 @@ DynamicLoaderMacOSXDYLD::GetStepThroughTrampolinePlan (Thread &thread, bool stop { SymbolContextList target_symbols; TargetSP target_sp (thread.CalculateTarget()); - ModuleList &images = target_sp->GetImages(); + const ModuleList &images = target_sp->GetImages(); images.FindSymbolsWithNameAndType(trampoline_name, eSymbolTypeCode, target_symbols); diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp index 251590fac16..1400427094b 100644 --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.cpp @@ -271,9 +271,8 @@ DynamicLoaderPOSIXDYLD::RefreshModules() FileSpec file(I->path.c_str(), true); ModuleSP module_sp = LoadModuleAtAddress(file, I->base_addr); if (module_sp.get()) - new_modules.Append(module_sp); + loaded_modules.AppendIfNeeded(module_sp); } - m_process->GetTarget().ModulesDidLoad(new_modules); } if (m_rendezvous.ModulesDidUnload()) @@ -290,7 +289,7 @@ DynamicLoaderPOSIXDYLD::RefreshModules() if (module_sp.get()) old_modules.Append(module_sp); } - m_process->GetTarget().ModulesDidUnload(old_modules); + loaded_modules.Remove(old_modules); } } @@ -312,7 +311,7 @@ DynamicLoaderPOSIXDYLD::GetStepThroughTrampolinePlan(Thread &thread, bool stop) SymbolContextList target_symbols; Target &target = thread.GetProcess()->GetTarget(); - ModuleList &images = target.GetImages(); + const ModuleList &images = target.GetImages(); images.FindSymbolsWithNameAndType(sym_name, eSymbolTypeCode, target_symbols); size_t num_targets = target_symbols.GetSize(); diff --git a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp index 9b15ea8e49c..f27f0a19d5d 100644 --- a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp +++ b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp @@ -95,7 +95,7 @@ DynamicLoaderStatic::DidLaunch () void DynamicLoaderStatic::LoadAllImagesAtFileAddresses () { - ModuleList &module_list = m_process->GetTarget().GetImages(); + const ModuleList &module_list = m_process->GetTarget().GetImages(); ModuleList loaded_module_list; @@ -143,8 +143,7 @@ DynamicLoaderStatic::LoadAllImagesAtFileAddresses () } } - if (loaded_module_list.GetSize()) - m_process->GetTarget().ModulesDidLoad (loaded_module_list); + m_process->GetTarget().ModulesDidLoad (loaded_module_list); } ThreadPlanSP diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index 995a438ca89..a49b2137f1d 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -178,7 +178,7 @@ AppleObjCRuntime::GetObjCModule () Process *process = GetProcess(); if (process) { - ModuleList& modules = process->GetTarget().GetImages(); + const ModuleList& modules = process->GetTarget().GetImages(); for (uint32_t idx = 0; idx < modules.GetSize(); idx++) { module_sp = modules.GetModuleAtIndex(idx); @@ -197,7 +197,7 @@ AppleObjCRuntime::GetPrintForDebuggerAddr() { if (!m_PrintForDebugger_addr.get()) { - ModuleList &modules = m_process->GetTarget().GetImages(); + const ModuleList &modules = m_process->GetTarget().GetImages(); SymbolContextList contexts; SymbolContext context; @@ -289,7 +289,7 @@ AppleObjCRuntime::GetObjCVersion (Process *process, ModuleSP &objc_module_sp) return eObjC_VersionUnknown; Target &target = process->GetTarget(); - ModuleList &target_modules = target.GetImages(); + const ModuleList &target_modules = target.GetImages(); Mutex::Locker modules_locker(target_modules.GetMutex()); size_t num_images = target_modules.GetSize(); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 4b13cba5bb6..5b758c86ca5 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -1617,7 +1617,7 @@ protected: { if (!target_sp) return eLazyBoolCalculate; - ModuleList& modules = target_sp->GetImages(); + const ModuleList& modules = target_sp->GetImages(); for (uint32_t idx = 0; idx < modules.GetSize(); idx++) { lldb::ModuleSP module_sp = modules.GetModuleAtIndex(idx); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp index d84bccd69b6..25a2bfa4f7f 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -334,7 +334,7 @@ AppleObjCTrampolineHandler::AppleObjCVTables::InitializeVTableSymbols () return true; Target &target = m_process_sp->GetTarget(); - ModuleList &target_modules = target.GetImages(); + const ModuleList &target_modules = target.GetImages(); Mutex::Locker modules_locker(target_modules.GetMutex()); size_t num_modules = target_modules.GetSize(); if (!m_objc_module_sp) diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp index 7deadc0a493..a0d47b95c90 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -18,6 +18,7 @@ #include "lldb/Core/Error.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" +#include "lldb/Core/Timer.h" #include "lldb/Host/Host.h" #include "lldb/Host/Symbols.h" #include "lldb/Symbol/ObjectFile.h" @@ -47,6 +48,37 @@ PlatformDarwin::~PlatformDarwin() { } +FileSpec +PlatformDarwin::LocateExecutableScriptingResource (const ModuleSpec &module_spec) +{ + const FileSpec *exec_fspec = module_spec.GetFileSpecPtr(); + const ArchSpec *arch = module_spec.GetArchitecturePtr(); + const UUID *uuid = module_spec.GetUUIDPtr(); + + Timer scoped_timer (__PRETTY_FUNCTION__, + "LocateExecutableScriptingResource (file = %s, arch = %s, uuid = %p)", + exec_fspec ? exec_fspec->GetFilename().AsCString ("<NULL>") : "<NULL>", + arch ? arch->GetArchitectureName() : "<NULL>", + uuid); + + + FileSpec symbol_fspec (Symbols::LocateExecutableSymbolFile(module_spec)); + + FileSpec script_fspec; + + if (symbol_fspec && symbol_fspec.Exists()) + { + // for OSX we are going to be in .dSYM/Contents/Resources/DWARF/<basename> + // let us go to .dSYM/Contents/Resources/Python/<basename>.py and see if the file exists + StreamString path_string; + path_string.Printf("%s/../Python/%s.py",symbol_fspec.GetDirectory().GetCString(),module_spec.GetFileSpec().GetFileNameStrippingExtension().GetCString()); + script_fspec.SetFile(path_string.GetData(), true); + if (!script_fspec.Exists()) + script_fspec.Clear(); + } + + return script_fspec; +} Error PlatformDarwin::ResolveExecutable (const FileSpec &exe_file, diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h index 9376a660bcc..ddb3ead0202 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h @@ -38,6 +38,9 @@ public: const lldb_private::ModuleSpec &sym_spec, lldb_private::FileSpec &sym_file); + lldb_private::FileSpec + LocateExecutableScriptingResource (const lldb_private::ModuleSpec &module_spec); + virtual lldb_private::Error GetSharedModule (const lldb_private::ModuleSpec &module_spec, lldb::ModuleSP &module_sp, |

