summaryrefslogtreecommitdiffstats
path: root/lldb/include
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-02-05 02:38:54 +0000
committerGreg Clayton <gclayton@apple.com>2012-02-05 02:38:54 +0000
commitc96605461cddc640730fcbe93f35059a444a335c (patch)
treed82f72f7ea9da116705150fcfa3993442c0c135b /lldb/include
parent6987fdb6208b491fb31d5599eeed6ea2f2c9f30d (diff)
downloadbcm5719-llvm-c96605461cddc640730fcbe93f35059a444a335c.tar.gz
bcm5719-llvm-c96605461cddc640730fcbe93f35059a444a335c.zip
<rdar://problem/10560053>
Fixed "target modules list" (aliased to "image list") to output more information by default. Modified the "target modules list" to have a few new options: "--header" or "-h" => show the image header address "--offset" or "-o" => show the image header address offset from the address in the file (the slide applied to the shared library) Removed the "--symfile-basename" or "-S" option, and repurposed it to "--symfile-unique" "-S" which will show the symbol file if it differs from the executable file. ObjectFile's can now be loaded from memory for cases where we don't have the files cached locally in an SDK or net mounted root. ObjectFileMachO can now read mach files from memory. Moved the section data reading code into the ObjectFile so that the object file can get the section data from Process memory if the file is only in memory. lldb_private::Module can now load its object file in a target with a rigid slide (very common operation for most dynamic linkers) by using: bool Module::SetLoadAddress (Target &target, lldb::addr_t offset, bool &changed) lldb::SBModule() now has a new constructor in the public interface: SBModule::SBModule (lldb::SBProcess &process, lldb::addr_t header_addr); This will find an appropriate ObjectFile plug-in to load an image from memory where the object file header is at "header_addr". llvm-svn: 149804
Diffstat (limited to 'lldb/include')
-rw-r--r--lldb/include/lldb/API/SBModule.h3
-rw-r--r--lldb/include/lldb/API/SBProcess.h1
-rw-r--r--lldb/include/lldb/Core/Module.h39
-rw-r--r--lldb/include/lldb/Core/PluginManager.h9
-rw-r--r--lldb/include/lldb/Core/Section.h9
-rw-r--r--lldb/include/lldb/Symbol/DWARFCallFrameInfo.h2
-rw-r--r--lldb/include/lldb/Symbol/ObjectFile.h67
-rw-r--r--lldb/include/lldb/Target/Process.h4
-rw-r--r--lldb/include/lldb/lldb-private-interfaces.h1
9 files changed, 124 insertions, 11 deletions
diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h
index f4255742b81..58420c97231 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -31,6 +31,9 @@ public:
operator = (const SBModule &rhs);
#endif
+ SBModule (lldb::SBProcess &process,
+ lldb::addr_t header_addr);
+
~SBModule ();
bool
diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h
index 3880c2cd331..db636a9727e 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -193,6 +193,7 @@ protected:
friend class SBCommandInterpreter;
friend class SBDebugger;
friend class SBFunction;
+ friend class SBModule;
friend class SBTarget;
friend class SBThread;
friend class SBValue;
diff --git a/lldb/include/lldb/Core/Module.h b/lldb/include/lldb/Core/Module.h
index 2e187ee0ae6..0df8ca5aec8 100644
--- a/lldb/include/lldb/Core/Module.h
+++ b/lldb/include/lldb/Core/Module.h
@@ -96,12 +96,51 @@ public:
const ConstString *object_name = NULL,
off_t object_offset = 0);
+ Module (const FileSpec& file_spec,
+ const lldb::ProcessSP &processSP,
+ lldb::addr_t header_addr);
//------------------------------------------------------------------
/// Destructor.
//------------------------------------------------------------------
virtual
~Module ();
+
+ //------------------------------------------------------------------
+ /// Set the load address for all sections in a module to be the
+ /// file address plus \a slide.
+ ///
+ /// Many times a module will be loaded in a target with a constant
+ /// offset applied to all top level sections. This function can
+ /// set the load address for all top level sections to be the
+ /// section file address + offset.
+ ///
+ /// @param[in] target
+ /// The target in which to apply the section load addresses.
+ ///
+ /// @param[in] offset
+ /// The offset to apply to all file addresses for all top
+ /// level sections in the object file as each section load
+ /// address is being set.
+ ///
+ /// @param[out] changed
+ /// If any section load addresses were changed in \a target,
+ /// then \a changed will be set to \b true. Else \a changed
+ /// will be set to false. This allows this function to be
+ /// called multiple times on the same module for the same
+ /// target. If the module hasn't moved, then \a changed will
+ /// be false and no module updated notification will need to
+ /// be sent out.
+ ///
+ /// @returns
+ /// /b True if any sections were successfully loaded in \a target,
+ /// /b false otherwise.
+ //------------------------------------------------------------------
+ bool
+ SetLoadAddress (Target &target,
+ lldb::addr_t offset,
+ bool &changed);
+
//------------------------------------------------------------------
/// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
///
diff --git a/lldb/include/lldb/Core/PluginManager.h b/lldb/include/lldb/Core/PluginManager.h
index 9493755fa0a..fd014367d8f 100644
--- a/lldb/include/lldb/Core/PluginManager.h
+++ b/lldb/include/lldb/Core/PluginManager.h
@@ -137,17 +137,24 @@ public:
static bool
RegisterPlugin (const char *name,
const char *description,
- ObjectFileCreateInstance create_callback);
+ ObjectFileCreateInstance create_callback,
+ ObjectFileCreateMemoryInstance create_memory_callback);
static bool
UnregisterPlugin (ObjectFileCreateInstance create_callback);
static ObjectFileCreateInstance
GetObjectFileCreateCallbackAtIndex (uint32_t idx);
+
+ static ObjectFileCreateMemoryInstance
+ GetObjectFileCreateMemoryCallbackAtIndex (uint32_t idx);
static ObjectFileCreateInstance
GetObjectFileCreateCallbackForPluginName (const char *name);
+ static ObjectFileCreateMemoryInstance
+ GetObjectFileCreateMemoryCallbackForPluginName (const char *name);
+
//------------------------------------------------------------------
// ObjectContainer
diff --git a/lldb/include/lldb/Core/Section.h b/lldb/include/lldb/Core/Section.h
index a536f3d3473..ab28ce36cd9 100644
--- a/lldb/include/lldb/Core/Section.h
+++ b/lldb/include/lldb/Core/Section.h
@@ -226,15 +226,6 @@ public:
bool
IsDescendant (const Section *section);
- size_t
- MemoryMapSectionDataFromObjectFile (const ObjectFile* file, DataExtractor& section_data) const;
-
- size_t
- ReadSectionDataFromObjectFile (const ObjectFile* objfile, off_t section_offset, void *dst, size_t dst_len) const;
-
- size_t
- ReadSectionDataFromObjectFile (const ObjectFile* file, DataExtractor& section_data) const;
-
ConstString&
GetName ();
diff --git a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
index bd646d15068..e0ec07cc477 100644
--- a/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
+++ b/lldb/include/lldb/Symbol/DWARFCallFrameInfo.h
@@ -118,7 +118,7 @@ private:
GetCFIData();
ObjectFile& m_objfile;
- lldb::SectionSP m_section;
+ lldb::SectionSP m_section_sp;
lldb::RegisterKind m_reg_kind;
Flags m_flags;
cie_map_t m_cie_map;
diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h
index 6b356e5c1b4..f35e63213ca 100644
--- a/lldb/include/lldb/Symbol/ObjectFile.h
+++ b/lldb/include/lldb/Symbol/ObjectFile.h
@@ -91,6 +91,11 @@ public:
lldb::addr_t length,
lldb::DataBufferSP& headerDataSP);
+ ObjectFile (Module* module,
+ const lldb::ProcessSP &process_sp,
+ lldb::addr_t header_addr,
+ lldb::DataBufferSP& headerDataSP);
+
//------------------------------------------------------------------
/// Destructor.
///
@@ -147,6 +152,29 @@ public:
lldb::DataBufferSP &data_sp);
//------------------------------------------------------------------
+ /// Find a ObjectFile plug-in that can parse a file in memory.
+ ///
+ /// Scans all loaded plug-in interfaces that implement versions of
+ /// the ObjectFile plug-in interface and returns the first
+ /// instance that can parse the file.
+ ///
+ /// @param[in] module
+ /// The parent module that owns this object file.
+ ///
+ /// @param[in] process_sp
+ /// A shared pointer to the process whose memory space contains
+ /// an object file. This will be stored as a std::weak_ptr.
+ ///
+ /// @param[in] header_addr
+ /// The address of the header for the object file in memory.
+ //------------------------------------------------------------------
+ static lldb::ObjectFileSP
+ FindPlugin (Module* module,
+ const lldb::ProcessSP &process_sp,
+ lldb::addr_t header_addr,
+ lldb::DataBufferSP &file_data_sp);
+
+ //------------------------------------------------------------------
/// Gets the address size in bytes for the current object file.
///
/// @return
@@ -372,6 +400,22 @@ public:
GetEntryPointAddress () { return Address();}
//------------------------------------------------------------------
+ /// Returns the address that represents the header of this object
+ /// file.
+ ///
+ /// The header address is defined as where the header for the object
+ /// file is that describes the content of the file. If the header
+ /// doesn't appear in a section that is defined in the object file,
+ /// an address with no section is returned that has the file offset
+ /// set in the m_offset member of the lldb_private::Address object.
+ ///
+ /// @return
+ /// Returns the entry address for this module.
+ //------------------------------------------------------------------
+ virtual lldb_private::Address
+ GetHeaderAddress () { return Address();}
+
+ //------------------------------------------------------------------
/// The object file should be able to calculate its type by looking
/// at its file header and possibly the sections or other data in
/// the object file. The file type is used in the debugger to help
@@ -421,12 +465,33 @@ public:
return m_strata;
}
+ // When an object file is in memory, subclasses should try and lock
+ // the process weak pointer. If the process weak pointer produces a
+ // valid ProcessSP, then subclasses can call this function to read
+ // memory.
+ static lldb::DataBufferSP
+ ReadMemory (const lldb::ProcessSP &process_sp,
+ lldb::addr_t addr,
+ size_t byte_size);
+
size_t
GetData (off_t offset, size_t length, DataExtractor &data) const;
size_t
CopyData (off_t offset, size_t length, void *dst) const;
+ size_t
+ ReadSectionData (const Section *section,
+ off_t section_offset,
+ void *dst,
+ size_t dst_len) const;
+ size_t
+ ReadSectionData (const Section *section,
+ DataExtractor& section_data) const;
+
+ size_t
+ MemoryMapSectionData (const Section *section,
+ DataExtractor& section_data) const;
protected:
//------------------------------------------------------------------
// Member variables.
@@ -438,6 +503,8 @@ protected:
lldb::addr_t m_length; ///< The length of this object file if it is known (can be zero if length is unknown or can't be determined).
DataExtractor m_data; ///< The data for this object file so things can be parsed lazily.
lldb_private::UnwindTable m_unwind_table; /// < Table of FuncUnwinders objects created for this ObjectFile's functions
+ lldb::ProcessWP m_process_wp;
+ const bool m_in_memory;
//------------------------------------------------------------------
/// Sets the architecture for a module. At present the architecture
diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h
index 8a1438c0b79..f8e21bc1039 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -2574,6 +2574,10 @@ public:
return error;
}
+ lldb::ModuleSP
+ ReadModuleFromMemory (const FileSpec& file_spec,
+ lldb::addr_t header_addr);
+
//------------------------------------------------------------------
/// Attempt to get the attributes for a region of memory in the process.
///
diff --git a/lldb/include/lldb/lldb-private-interfaces.h b/lldb/include/lldb/lldb-private-interfaces.h
index 16c8778e014..1e95c04a936 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -21,6 +21,7 @@ namespace lldb_private
typedef DynamicLoader* (*DynamicLoaderCreateInstance) (Process* process, bool force);
typedef ObjectContainer* (*ObjectContainerCreateInstance) (Module* module, lldb::DataBufferSP& dataSP, const FileSpec *file, lldb::addr_t offset, lldb::addr_t length);
typedef ObjectFile* (*ObjectFileCreateInstance) (Module* module, lldb::DataBufferSP& dataSP, const FileSpec* file, lldb::addr_t offset, lldb::addr_t length);
+ typedef ObjectFile* (*ObjectFileCreateMemoryInstance) (Module* module, lldb::DataBufferSP& dataSP, const lldb::ProcessSP &process_sp, lldb::addr_t offset);
typedef LogChannel* (*LogChannelCreateInstance) ();
typedef EmulateInstruction * (*EmulateInstructionCreateInstance) (const ArchSpec &arch, InstructionType inst_type);
typedef OperatingSystem* (*OperatingSystemCreateInstance) (Process *process, bool force);
OpenPOWER on IntegriCloud