summaryrefslogtreecommitdiff
path: root/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h')
-rw-r--r--source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h226
1 files changed, 22 insertions, 204 deletions
diff --git a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
index 8fd60d0b6ac7d..637bd8640d248 100644
--- a/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
+++ b/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
@@ -13,6 +13,7 @@
// C Includes
// C++ Includes
#include <vector>
+#include <mutex>
// Other libraries and framework includes
// Project includes
@@ -20,16 +21,17 @@
#include "lldb/Host/FileSpec.h"
#include "lldb/Core/StructuredData.h"
#include "lldb/Core/UUID.h"
-#include "lldb/Host/Mutex.h"
#include "lldb/Target/Process.h"
#include "lldb/Utility/SafeMachO.h"
-class DynamicLoaderMacOSXDYLD : public lldb_private::DynamicLoader
+#include "DynamicLoaderDarwin.h"
+
+class DynamicLoaderMacOSXDYLD : public lldb_private::DynamicLoaderDarwin
{
public:
DynamicLoaderMacOSXDYLD(lldb_private::Process *process);
- ~DynamicLoaderMacOSXDYLD() override;
+ virtual ~DynamicLoaderMacOSXDYLD() override;
//------------------------------------------------------------------
// Static Functions
@@ -55,24 +57,9 @@ public:
/// Allow DynamicLoader plug-ins to execute some code after
/// attaching to a process.
//------------------------------------------------------------------
- void
- DidAttach() override;
-
- void
- DidLaunch() override;
-
bool
ProcessDidExec() override;
- lldb::ThreadPlanSP
- GetStepThroughTrampolinePlan(lldb_private::Thread &thread,
- bool stop_others) override;
-
- size_t
- FindEquivalentSymbols(lldb_private::Symbol *original_symbol,
- lldb_private::ModuleList &module_list,
- lldb_private::SymbolContextList &equivalent_symbols) override;
-
lldb_private::Error
CanLoadImage() override;
@@ -85,28 +72,21 @@ public:
uint32_t
GetPluginVersion() override;
- bool
- AlwaysRelyOnEHUnwindInfo(lldb_private::SymbolContext &sym_ctx) override;
-
protected:
void
- PrivateInitialize (lldb_private::Process *process);
+ PutToLog(lldb_private::Log *log) const;
void
- PrivateProcessStateChanged (lldb_private::Process *process,
- lldb::StateType state);
+ DoInitialImageFetch () override;
bool
- LocateDYLD ();
+ NeedToDoInitialImageFetch () override;
bool
- DidSetNotificationBreakpoint () const;
-
- void
- Clear (bool clear_process);
+ DidSetNotificationBreakpoint () override;
void
- PutToLog (lldb_private::Log *log) const;
+ DoClear () override;
bool
ReadDYLDInfoFromMemoryAndSetNotificationCallback (lldb::addr_t addr);
@@ -120,141 +100,15 @@ protected:
uint32_t
AddrByteSize();
- static lldb::ByteOrder
- GetByteOrderFromMagic (uint32_t magic);
-
bool
ReadMachHeader (lldb::addr_t addr,
llvm::MachO::mach_header *header,
lldb_private::DataExtractor *load_command_data);
- class Segment
- {
- public:
- Segment() :
- name(),
- vmaddr(LLDB_INVALID_ADDRESS),
- vmsize(0),
- fileoff(0),
- filesize(0),
- maxprot(0),
- initprot(0),
- nsects(0),
- flags(0)
- {
- }
-
- lldb_private::ConstString name;
- lldb::addr_t vmaddr;
- lldb::addr_t vmsize;
- lldb::addr_t fileoff;
- lldb::addr_t filesize;
- uint32_t maxprot;
- uint32_t initprot;
- uint32_t nsects;
- uint32_t flags;
-
- bool
- operator==(const Segment& rhs) const
- {
- return name == rhs.name && vmaddr == rhs.vmaddr && vmsize == rhs.vmsize;
- }
-
- void
- PutToLog (lldb_private::Log *log,
- lldb::addr_t slide) const;
-
- };
-
- struct DYLDImageInfo
- {
- lldb::addr_t address; // Address of mach header for this dylib
- lldb::addr_t slide; // The amount to slide all segments by if there is a global slide.
- lldb::addr_t mod_date; // Modification date for this dylib
- lldb_private::FileSpec file_spec; // Resolved path for this dylib
- lldb_private::UUID uuid; // UUID for this dylib if it has one, else all zeros
- llvm::MachO::mach_header header; // The mach header for this image
- std::vector<Segment> segments; // All segment vmaddr and vmsize pairs for this executable (from memory of inferior)
- uint32_t load_stop_id; // The process stop ID that the sections for this image were loaded
-
- DYLDImageInfo() :
- address(LLDB_INVALID_ADDRESS),
- slide(0),
- mod_date(0),
- file_spec(),
- uuid(),
- header(),
- segments(),
- load_stop_id(0)
- {
- }
-
- void
- Clear(bool load_cmd_data_only)
- {
- if (!load_cmd_data_only)
- {
- address = LLDB_INVALID_ADDRESS;
- slide = 0;
- mod_date = 0;
- file_spec.Clear();
- ::memset (&header, 0, sizeof(header));
- }
- uuid.Clear();
- segments.clear();
- load_stop_id = 0;
- }
-
- bool
- operator == (const DYLDImageInfo& rhs) const
- {
- return address == rhs.address
- && slide == rhs.slide
- && mod_date == rhs.mod_date
- && file_spec == rhs.file_spec
- && uuid == rhs.uuid
- && memcmp(&header, &rhs.header, sizeof(header)) == 0
- && segments == rhs.segments;
- }
-
- bool
- UUIDValid() const
- {
- return uuid.IsValid();
- }
-
- uint32_t
- GetAddressByteSize ()
- {
- if (header.cputype)
- {
- if (header.cputype & llvm::MachO::CPU_ARCH_ABI64)
- return 8;
- else
- return 4;
- }
- return 0;
- }
-
- lldb::ByteOrder
- GetByteOrder();
-
- lldb_private::ArchSpec
- GetArchitecture () const
- {
- return lldb_private::ArchSpec (lldb_private::eArchTypeMachO, header.cputype, header.cpusubtype);
- }
-
- const Segment *
- FindSegment (const lldb_private::ConstString &name) const;
-
- void
- PutToLog (lldb_private::Log *log) const;
-
- typedef std::vector<DYLDImageInfo> collection;
- typedef collection::iterator iterator;
- typedef collection::const_iterator const_iterator;
- };
+ uint32_t
+ ParseLoadCommands (const lldb_private::DataExtractor& data,
+ ImageInfo& dylib_info,
+ lldb_private::FileSpec *lc_id_dylinker);
struct DYLDAllImageInfos
{
@@ -296,38 +150,14 @@ protected:
}
};
- void
- RegisterNotificationCallbacks();
-
- void
- UnregisterNotificationCallbacks();
-
- uint32_t
- ParseLoadCommands (const lldb_private::DataExtractor& data,
- DYLDImageInfo& dylib_info,
- lldb_private::FileSpec *lc_id_dylinker);
-
- bool
- UpdateImageLoadAddress(lldb_private::Module *module,
- DYLDImageInfo& info);
-
- bool
- UnloadImageLoadAddress (lldb_private::Module *module,
- DYLDImageInfo& info);
-
- lldb::ModuleSP
- FindTargetModuleForDYLDImageInfo (DYLDImageInfo &image_info,
- bool can_create,
- bool *did_create_ptr);
-
- DYLDImageInfo *
- GetImageInfo (lldb_private::Module *module);
+ static lldb::ByteOrder
+ GetByteOrderFromMagic(uint32_t magic);
bool
- NeedToLocateDYLD () const;
+ SetNotificationBreakpoint () override;
- bool
- SetNotificationBreakpoint ();
+ void
+ ClearNotificationBreakpoint () override;
// There is a little tricky bit where you might initially attach while dyld is updating
// the all_image_infos, and you can't read the infos, so you have to continue and pick it
@@ -344,38 +174,26 @@ protected:
ReadAllImageInfosStructure ();
bool
- AddModulesUsingInfosFromDebugserver (lldb_private::StructuredData::ObjectSP image_details, DYLDImageInfo::collection &image_infos);
-
- bool
AddModulesUsingImageInfosAddress (lldb::addr_t image_infos_addr, uint32_t image_infos_count);
bool
- AddModulesUsingImageInfos (DYLDImageInfo::collection &image_infos);
-
- bool
RemoveModulesUsingImageInfosAddress (lldb::addr_t image_infos_addr, uint32_t image_infos_count);
void
- UpdateImageInfosHeaderAndLoadCommands(DYLDImageInfo::collection &image_infos,
+ UpdateImageInfosHeaderAndLoadCommands(ImageInfo::collection &image_infos,
uint32_t infos_count,
bool update_executable);
bool
ReadImageInfos (lldb::addr_t image_infos_addr,
uint32_t image_infos_count,
- DYLDImageInfo::collection &image_infos);
-
+ ImageInfo::collection &image_infos);
- DYLDImageInfo m_dyld; // Info about the current dyld being used
- lldb::ModuleWP m_dyld_module_wp;
lldb::addr_t m_dyld_all_image_infos_addr;
DYLDAllImageInfos m_dyld_all_image_infos;
uint32_t m_dyld_all_image_infos_stop_id;
lldb::user_id_t m_break_id;
- DYLDImageInfo::collection m_dyld_image_infos; // Current shared libraries information
- uint32_t m_dyld_image_infos_stop_id; // The process stop ID that "m_dyld_image_infos" is valid for
- mutable lldb_private::Mutex m_mutex;
- lldb_private::Process::Notifications m_notification_callbacks;
+ mutable std::recursive_mutex m_mutex;
bool m_process_image_addr_is_all_images_infos;
private: