diff options
| author | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
|---|---|---|
| committer | Kate Stone <katherine.stone@apple.com> | 2016-09-06 20:57:50 +0000 |
| commit | b9c1b51e45b845debb76d8658edabca70ca56079 (patch) | |
| tree | dfcb5a13ef2b014202340f47036da383eaee74aa /lldb/source/Plugins/DynamicLoader/Static | |
| parent | d5aa73376966339caad04013510626ec2e42c760 (diff) | |
| download | bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.tar.gz bcm5719-llvm-b9c1b51e45b845debb76d8658edabca70ca56079.zip | |
*** This commit represents a complete reformatting of the LLDB source code
*** to conform to clang-format’s LLVM style. This kind of mass change has
*** two obvious implications:
Firstly, merging this particular commit into a downstream fork may be a huge
effort. Alternatively, it may be worth merging all changes up to this commit,
performing the same reformatting operation locally, and then discarding the
merge for this particular commit. The commands used to accomplish this
reformatting were as follows (with current working directory as the root of
the repository):
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} +
find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ;
The version of clang-format used was 3.9.0, and autopep8 was 1.2.4.
Secondly, “blame” style tools will generally point to this commit instead of
a meaningful prior commit. There are alternatives available that will attempt
to look through this change and find the appropriate prior commit. YMMV.
llvm-svn: 280751
Diffstat (limited to 'lldb/source/Plugins/DynamicLoader/Static')
| -rw-r--r-- | lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp | 230 | ||||
| -rw-r--r-- | lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h | 76 |
2 files changed, 126 insertions, 180 deletions
diff --git a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp index daa21adf3a9..04f1f339057 100644 --- a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp +++ b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.cpp @@ -23,50 +23,42 @@ using namespace lldb_private; // the plugin info class that gets handed out by the plugin factory and // allows the lldb to instantiate an instance of this class. //---------------------------------------------------------------------- -DynamicLoader * -DynamicLoaderStatic::CreateInstance (Process* process, bool force) -{ - bool create = force; - if (!create) - { - const llvm::Triple &triple_ref = process->GetTarget().GetArchitecture().GetTriple(); - const llvm::Triple::OSType os_type = triple_ref.getOS(); - if ((os_type == llvm::Triple::UnknownOS)) - create = true; +DynamicLoader *DynamicLoaderStatic::CreateInstance(Process *process, + bool force) { + bool create = force; + if (!create) { + const llvm::Triple &triple_ref = + process->GetTarget().GetArchitecture().GetTriple(); + const llvm::Triple::OSType os_type = triple_ref.getOS(); + if ((os_type == llvm::Triple::UnknownOS)) + create = true; + } + + if (!create) { + Module *exe_module = process->GetTarget().GetExecutableModulePointer(); + if (exe_module) { + ObjectFile *object_file = exe_module->GetObjectFile(); + if (object_file) { + create = (object_file->GetStrata() == ObjectFile::eStrataRawImage); + } } - - if (!create) - { - Module *exe_module = process->GetTarget().GetExecutableModulePointer(); - if (exe_module) - { - ObjectFile *object_file = exe_module->GetObjectFile(); - if (object_file) - { - create = (object_file->GetStrata() == ObjectFile::eStrataRawImage); - } - } - } - - if (create) - return new DynamicLoaderStatic (process); - return NULL; + } + + if (create) + return new DynamicLoaderStatic(process); + return NULL; } //---------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------- -DynamicLoaderStatic::DynamicLoaderStatic (Process* process) : - DynamicLoader(process) -{ -} +DynamicLoaderStatic::DynamicLoaderStatic(Process *process) + : DynamicLoader(process) {} //---------------------------------------------------------------------- // Destructor //---------------------------------------------------------------------- -DynamicLoaderStatic::~DynamicLoaderStatic() -{ -} +DynamicLoaderStatic::~DynamicLoaderStatic() {} //------------------------------------------------------------------ /// Called after attaching a process. @@ -74,11 +66,7 @@ DynamicLoaderStatic::~DynamicLoaderStatic() /// Allow DynamicLoader plug-ins to execute some code after /// attaching to a process. //------------------------------------------------------------------ -void -DynamicLoaderStatic::DidAttach () -{ - LoadAllImagesAtFileAddresses(); -} +void DynamicLoaderStatic::DidAttach() { LoadAllImagesAtFileAddresses(); } //------------------------------------------------------------------ /// Called after attaching a process. @@ -86,124 +74,94 @@ DynamicLoaderStatic::DidAttach () /// Allow DynamicLoader plug-ins to execute some code after /// attaching to a process. //------------------------------------------------------------------ -void -DynamicLoaderStatic::DidLaunch () -{ - LoadAllImagesAtFileAddresses(); -} - -void -DynamicLoaderStatic::LoadAllImagesAtFileAddresses () -{ - const ModuleList &module_list = m_process->GetTarget().GetImages(); - - ModuleList loaded_module_list; - - // Disable JIT for static dynamic loader targets - m_process->SetCanJIT(false); - - std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex()); - - const size_t num_modules = module_list.GetSize(); - for (uint32_t idx = 0; idx < num_modules; ++idx) - { - ModuleSP module_sp (module_list.GetModuleAtIndexUnlocked (idx)); - if (module_sp) - { - bool changed = false; - ObjectFile *image_object_file = module_sp->GetObjectFile(); - if (image_object_file) - { - SectionList *section_list = image_object_file->GetSectionList (); - if (section_list) - { - // All sections listed in the dyld image info structure will all - // either be fixed up already, or they will all be off by a single - // slide amount that is determined by finding the first segment - // that is at file offset zero which also has bytes (a file size - // that is greater than zero) in the object file. - - // Determine the slide amount (if any) - 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 the - // first section that starts of file offset zero and that - // has bytes in the file... - SectionSP section_sp (section_list->GetSectionAtIndex (sect_idx)); - if (section_sp) - { - if (m_process->GetTarget().SetSectionLoadAddress (section_sp, section_sp->GetFileAddress())) - changed = true; - } - } - } +void DynamicLoaderStatic::DidLaunch() { LoadAllImagesAtFileAddresses(); } + +void DynamicLoaderStatic::LoadAllImagesAtFileAddresses() { + const ModuleList &module_list = m_process->GetTarget().GetImages(); + + ModuleList loaded_module_list; + + // Disable JIT for static dynamic loader targets + m_process->SetCanJIT(false); + + std::lock_guard<std::recursive_mutex> guard(module_list.GetMutex()); + + const size_t num_modules = module_list.GetSize(); + for (uint32_t idx = 0; idx < num_modules; ++idx) { + ModuleSP module_sp(module_list.GetModuleAtIndexUnlocked(idx)); + if (module_sp) { + bool changed = false; + ObjectFile *image_object_file = module_sp->GetObjectFile(); + if (image_object_file) { + SectionList *section_list = image_object_file->GetSectionList(); + if (section_list) { + // All sections listed in the dyld image info structure will all + // either be fixed up already, or they will all be off by a single + // slide amount that is determined by finding the first segment + // that is at file offset zero which also has bytes (a file size + // that is greater than zero) in the object file. + + // Determine the slide amount (if any) + 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 the + // first section that starts of file offset zero and that + // has bytes in the file... + SectionSP section_sp(section_list->GetSectionAtIndex(sect_idx)); + if (section_sp) { + if (m_process->GetTarget().SetSectionLoadAddress( + section_sp, section_sp->GetFileAddress())) + changed = true; } - - if (changed) - loaded_module_list.AppendIfNeeded (module_sp); + } } + } + + if (changed) + loaded_module_list.AppendIfNeeded(module_sp); } + } - m_process->GetTarget().ModulesDidLoad (loaded_module_list); + m_process->GetTarget().ModulesDidLoad(loaded_module_list); } ThreadPlanSP -DynamicLoaderStatic::GetStepThroughTrampolinePlan (Thread &thread, bool stop_others) -{ - return ThreadPlanSP(); +DynamicLoaderStatic::GetStepThroughTrampolinePlan(Thread &thread, + bool stop_others) { + return ThreadPlanSP(); } -Error -DynamicLoaderStatic::CanLoadImage () -{ - Error error; - error.SetErrorString ("can't load images on with a static debug session"); - return error; +Error DynamicLoaderStatic::CanLoadImage() { + Error error; + error.SetErrorString("can't load images on with a static debug session"); + return error; } -void -DynamicLoaderStatic::Initialize() -{ - PluginManager::RegisterPlugin (GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); +void DynamicLoaderStatic::Initialize() { + PluginManager::RegisterPlugin(GetPluginNameStatic(), + GetPluginDescriptionStatic(), CreateInstance); } -void -DynamicLoaderStatic::Terminate() -{ - PluginManager::UnregisterPlugin (CreateInstance); +void DynamicLoaderStatic::Terminate() { + PluginManager::UnregisterPlugin(CreateInstance); } - -lldb_private::ConstString -DynamicLoaderStatic::GetPluginNameStatic() -{ - static ConstString g_name("static"); - return g_name; +lldb_private::ConstString DynamicLoaderStatic::GetPluginNameStatic() { + static ConstString g_name("static"); + return g_name; } -const char * -DynamicLoaderStatic::GetPluginDescriptionStatic() -{ - return "Dynamic loader plug-in that will load any images at the static addresses contained in each image."; +const char *DynamicLoaderStatic::GetPluginDescriptionStatic() { + return "Dynamic loader plug-in that will load any images at the static " + "addresses contained in each image."; } - //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ -lldb_private::ConstString -DynamicLoaderStatic::GetPluginName() -{ - return GetPluginNameStatic(); -} - -uint32_t -DynamicLoaderStatic::GetPluginVersion() -{ - return 1; +lldb_private::ConstString DynamicLoaderStatic::GetPluginName() { + return GetPluginNameStatic(); } +uint32_t DynamicLoaderStatic::GetPluginVersion() { return 1; } diff --git a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h index 67694c96025..c6122edf50c 100644 --- a/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h +++ b/lldb/source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h @@ -14,69 +14,57 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Target/DynamicLoader.h" -#include "lldb/Host/FileSpec.h" #include "lldb/Core/UUID.h" +#include "lldb/Host/FileSpec.h" +#include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" -class DynamicLoaderStatic : public lldb_private::DynamicLoader -{ +class DynamicLoaderStatic : public lldb_private::DynamicLoader { public: - DynamicLoaderStatic(lldb_private::Process *process); + DynamicLoaderStatic(lldb_private::Process *process); - ~DynamicLoaderStatic() override; + ~DynamicLoaderStatic() override; - //------------------------------------------------------------------ - // Static Functions - //------------------------------------------------------------------ - static void - Initialize(); + //------------------------------------------------------------------ + // Static Functions + //------------------------------------------------------------------ + static void Initialize(); - static void - Terminate(); + static void Terminate(); - static lldb_private::ConstString - GetPluginNameStatic(); + static lldb_private::ConstString GetPluginNameStatic(); - static const char * - GetPluginDescriptionStatic(); + static const char *GetPluginDescriptionStatic(); - static lldb_private::DynamicLoader * - CreateInstance (lldb_private::Process *process, bool force); + static lldb_private::DynamicLoader * + CreateInstance(lldb_private::Process *process, bool force); - //------------------------------------------------------------------ - /// Called after attaching a process. - /// - /// Allow DynamicLoader plug-ins to execute some code after - /// attaching to a process. - //------------------------------------------------------------------ - void - DidAttach() override; + //------------------------------------------------------------------ + /// Called after attaching a process. + /// + /// Allow DynamicLoader plug-ins to execute some code after + /// attaching to a process. + //------------------------------------------------------------------ + void DidAttach() override; - void - DidLaunch() override; + void DidLaunch() override; - lldb::ThreadPlanSP - GetStepThroughTrampolinePlan(lldb_private::Thread &thread, - bool stop_others) override; + lldb::ThreadPlanSP GetStepThroughTrampolinePlan(lldb_private::Thread &thread, + bool stop_others) override; - lldb_private::Error - CanLoadImage() override; + lldb_private::Error CanLoadImage() override; - //------------------------------------------------------------------ - // PluginInterface protocol - //------------------------------------------------------------------ - lldb_private::ConstString - GetPluginName() override; + //------------------------------------------------------------------ + // PluginInterface protocol + //------------------------------------------------------------------ + lldb_private::ConstString GetPluginName() override; - uint32_t - GetPluginVersion() override; + uint32_t GetPluginVersion() override; private: - void - LoadAllImagesAtFileAddresses (); + void LoadAllImagesAtFileAddresses(); - DISALLOW_COPY_AND_ASSIGN (DynamicLoaderStatic); + DISALLOW_COPY_AND_ASSIGN(DynamicLoaderStatic); }; #endif // liblldb_DynamicLoaderStatic_h_ |

