[Lldb-commits] [lldb] r151336 - in /lldb/trunk: examples/darwin/heap_find/ include/lldb/ include/lldb/API/ include/lldb/Breakpoint/ include/lldb/Core/ include/lldb/Symbol/ lldb.xcodeproj/xcshareddata/xcschemes/ source/API/ source/Breakpoint/ source/Commands/ source/Core/ source/Expression/ source/Plugins/Disassembler/llvm/ source/Plugins/DynamicLoader/MacOSX-DYLD/ source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/ source/Plugins/ObjectContainer/BSD-Archive/ source...
Greg Clayton
gclayton at apple.com
Thu Feb 23 17:59:30 PST 2012
Author: gclayton
Date: Thu Feb 23 19:59:29 2012
New Revision: 151336
URL: http://llvm.org/viewvc/llvm-project?rev=151336&view=rev
Log:
<rdar://problem/10103468>
I started work on being able to add symbol files after a debug session
had started with a new "target symfile add" command and quickly ran into
problems with stale Address objects in breakpoint locations that had
lldb_private::Section pointers into modules that had been removed or
replaced. This also let to grabbing stale modules from those sections.
So I needed to thread harded the Address, Section and related objects.
To do this I modified the ModuleChild class to now require a ModuleSP
on initialization so that a weak reference can created. I also changed
all places that were handing out "Section *" to have them hand out SectionSP.
All ObjectFile, SymbolFile and SymbolVendors were inheriting from ModuleChild
so all of the find plug-in, static creation function and constructors now
require ModuleSP references instead of Module *.
Address objects now have weak references to their sections which can
safely go stale when a module gets destructed.
This checkin doesn't complete the "target symfile add" command, but it
does get us a lot clioser to being able to do such things without a high
risk of crashing or memory corruption.
Modified:
lldb/trunk/examples/darwin/heap_find/heap_find.c
lldb/trunk/include/lldb/API/SBSection.h
lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h
lldb/trunk/include/lldb/Core/Address.h
lldb/trunk/include/lldb/Core/AddressRange.h
lldb/trunk/include/lldb/Core/Module.h
lldb/trunk/include/lldb/Core/ModuleChild.h
lldb/trunk/include/lldb/Core/Section.h
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/include/lldb/Core/ValueObjectMemory.h
lldb/trunk/include/lldb/Core/ValueObjectVariable.h
lldb/trunk/include/lldb/Symbol/Block.h
lldb/trunk/include/lldb/Symbol/CompileUnit.h
lldb/trunk/include/lldb/Symbol/Function.h
lldb/trunk/include/lldb/Symbol/LineEntry.h
lldb/trunk/include/lldb/Symbol/LineTable.h
lldb/trunk/include/lldb/Symbol/ObjectContainer.h
lldb/trunk/include/lldb/Symbol/ObjectFile.h
lldb/trunk/include/lldb/Symbol/Symbol.h
lldb/trunk/include/lldb/Symbol/SymbolContextScope.h
lldb/trunk/include/lldb/Symbol/SymbolVendor.h
lldb/trunk/include/lldb/lldb-forward.h
lldb/trunk/include/lldb/lldb-private-interfaces.h
lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
lldb/trunk/source/API/SBAddress.cpp
lldb/trunk/source/API/SBBreakpoint.cpp
lldb/trunk/source/API/SBFunction.cpp
lldb/trunk/source/API/SBModule.cpp
lldb/trunk/source/API/SBSection.cpp
lldb/trunk/source/API/SBSymbol.cpp
lldb/trunk/source/API/SBTarget.cpp
lldb/trunk/source/API/SBThread.cpp
lldb/trunk/source/API/SBValue.cpp
lldb/trunk/source/Breakpoint/Breakpoint.cpp
lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp
lldb/trunk/source/Commands/CommandObjectArgs.cpp
lldb/trunk/source/Commands/CommandObjectMemory.cpp
lldb/trunk/source/Commands/CommandObjectTarget.cpp
lldb/trunk/source/Core/Address.cpp
lldb/trunk/source/Core/AddressRange.cpp
lldb/trunk/source/Core/DataExtractor.cpp
lldb/trunk/source/Core/Disassembler.cpp
lldb/trunk/source/Core/Module.cpp
lldb/trunk/source/Core/ModuleChild.cpp
lldb/trunk/source/Core/ModuleList.cpp
lldb/trunk/source/Core/Section.cpp
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/Core/ValueObjectChild.cpp
lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
lldb/trunk/source/Core/ValueObjectMemory.cpp
lldb/trunk/source/Core/ValueObjectVariable.cpp
lldb/trunk/source/Expression/ClangExpressionParser.cpp
lldb/trunk/source/Expression/ClangFunction.cpp
lldb/trunk/source/Expression/ClangUserExpression.cpp
lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp
lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h
lldb/trunk/source/Symbol/Block.cpp
lldb/trunk/source/Symbol/CompileUnit.cpp
lldb/trunk/source/Symbol/Function.cpp
lldb/trunk/source/Symbol/LineEntry.cpp
lldb/trunk/source/Symbol/LineTable.cpp
lldb/trunk/source/Symbol/ObjectFile.cpp
lldb/trunk/source/Symbol/Symbol.cpp
lldb/trunk/source/Symbol/SymbolVendor.cpp
lldb/trunk/source/Symbol/Type.cpp
lldb/trunk/source/Symbol/Variable.cpp
lldb/trunk/source/Target/SectionLoadList.cpp
lldb/trunk/source/Target/StackFrame.cpp
lldb/trunk/source/Target/Target.cpp
lldb/trunk/source/Target/ThreadPlanTracer.cpp
Modified: lldb/trunk/examples/darwin/heap_find/heap_find.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/examples/darwin/heap_find/heap_find.c?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/examples/darwin/heap_find/heap_find.c (original)
+++ lldb/trunk/examples/darwin/heap_find/heap_find.c Thu Feb 23 19:59:29 2012
@@ -199,6 +199,108 @@
}
}
+
+typedef uint64_t MachMallocEventId;
+
+enum MachMallocEventType
+{
+ eMachMallocEventTypeAlloc = 2,
+ eMachMallocEventTypeDealloc = 4,
+ eMachMallocEventTypeOther = 1
+};
+
+struct MachMallocEvent
+{
+ mach_vm_address_t m_base_address;
+ uint64_t m_size;
+ MachMallocEventType m_event_type;
+ MachMallocEventId m_event_id;
+};
+
+static void foundStackLog(mach_stack_logging_record_t record, void *context) {
+ *((bool*)context) = true;
+}
+
+bool
+malloc_stack_logging_is_enabled ()
+{
+ bool found = false;
+ __mach_stack_logging_enumerate_records(m_task, 0x0, foundStackLog, &found);
+ return found;
+}
+
+struct history_enumerator_impl_data
+{
+ MachMallocEvent *buffer;
+ uint32_t *position;
+ uint32_t count;
+};
+
+static void
+history_enumerator_impl(mach_stack_logging_record_t record, void* enum_obj)
+{
+ history_enumerator_impl_data *data = (history_enumerator_impl_data*)enum_obj;
+
+ if (*data->position >= data->count)
+ return;
+
+ data->buffer[*data->position].m_base_address = record.address;
+ data->buffer[*data->position].m_size = record.argument;
+ data->buffer[*data->position].m_event_id = record.stack_identifier;
+ data->buffer[*data->position].m_event_type = record.type_flags == stack_logging_type_alloc ? eMachMallocEventTypeAlloc :
+ record.type_flags == stack_logging_type_dealloc ? eMachMallocEventTypeDealloc :
+ eMachMallocEventTypeOther;
+ *data->position+=1;
+}
+
+bool
+MachTask::EnumerateMallocRecords (MachMallocEvent *event_buffer,
+ uint32_t buffer_size,
+ uint32_t *count)
+{
+ return EnumerateMallocRecords(0,
+ event_buffer,
+ buffer_size,
+ count);
+}
+
+bool
+MachTask::EnumerateMallocRecords (mach_vm_address_t address,
+ MachMallocEvent *event_buffer,
+ uint32_t buffer_size,
+ uint32_t *count)
+{
+ if (!event_buffer || !count)
+ return false;
+
+ if (buffer_size == 0)
+ return false;
+
+ *count = 0;
+ history_enumerator_impl_data data = { event_buffer, count, buffer_size };
+ __mach_stack_logging_enumerate_records(m_task, address, history_enumerator_impl, &data);
+ return (*count > 0);
+}
+
+bool
+MachTask::EnumerateMallocFrames (MachMallocEventId event_id,
+ mach_vm_address_t *function_addresses_buffer,
+ uint32_t buffer_size,
+ uint32_t *count)
+{
+ if (!function_addresses_buffer || !count)
+ return false;
+
+ if (buffer_size == 0)
+ return false;
+
+ __mach_stack_logging_frames_for_uniqued_stack(m_task, event_id, &function_addresses_buffer[0], buffer_size, count);
+ *count -= 1;
+ if (function_addresses_buffer[*count-1] < vm_page_size)
+ *count -= 1;
+ return (*count > 0);
+}
+
uint32_t
find_pointer_in_heap (intptr_t addr)
{
Modified: lldb/trunk/include/lldb/API/SBSection.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBSection.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBSection.h (original)
+++ lldb/trunk/include/lldb/API/SBSection.h Thu Feb 23 19:59:29 2012
@@ -80,15 +80,15 @@
friend class SBModule;
friend class SBTarget;
- SBSection (const lldb_private::Section *section);
+ SBSection (const lldb::SectionSP §ion_sp);
- const lldb_private::Section *
- GetSection();
+ lldb::SectionSP
+ GetSP() const;
void
- SetSection (const lldb_private::Section *section);
+ SetSP(const lldb::SectionSP §ion_sp);
- std::auto_ptr<lldb_private::SectionImpl> m_opaque_ap;
+ lldb::SectionWP m_opaque_wp;
};
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointLocationList.h Thu Feb 23 19:59:29 2012
@@ -248,6 +248,9 @@
AddLocation (const Address &addr,
bool *new_location = NULL);
+ bool
+ RemoveLocation (const lldb::BreakpointLocationSP &bp_loc_sp);
+
typedef std::vector<lldb::BreakpointLocationSP> collection;
typedef std::map<lldb_private::Address,
lldb::BreakpointLocationSP,
Modified: lldb/trunk/include/lldb/Core/Address.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Address.h (original)
+++ lldb/trunk/include/lldb/Core/Address.h Thu Feb 23 19:59:29 2012
@@ -97,7 +97,7 @@
/// offset (LLDB_INVALID_ADDRESS).
//------------------------------------------------------------------
Address () :
- m_section (NULL),
+ m_section_wp (),
m_offset (LLDB_INVALID_ADDRESS)
{
}
@@ -112,7 +112,7 @@
/// A const Address object reference to copy.
//------------------------------------------------------------------
Address (const Address& rhs) :
- m_section (rhs.m_section),
+ m_section_wp (rhs.m_section_wp),
m_offset (rhs.m_offset)
{
}
@@ -130,8 +130,8 @@
/// @param[in] offset
/// The offset in bytes into \a section.
//------------------------------------------------------------------
- Address (const Section* section, lldb::addr_t offset) :
- m_section (section),
+ Address (const lldb::SectionSP §ion_sp, lldb::addr_t offset) :
+ m_section_wp (section_sp),
m_offset (offset)
{
}
@@ -150,6 +150,8 @@
//------------------------------------------------------------------
Address (lldb::addr_t file_addr, const SectionList * section_list);
+ Address (lldb::addr_t abs_addr);
+
//------------------------------------------------------------------
/// Assignment operator.
///
@@ -175,7 +177,7 @@
void
Clear ()
{
- m_section = NULL;
+ m_section_wp.reset();
m_offset = LLDB_INVALID_ADDRESS;
}
@@ -344,7 +346,7 @@
bool
IsSectionOffset() const
{
- return m_section != NULL && IsValid();
+ return IsValid() && (GetSection().get() != NULL);
}
//------------------------------------------------------------------
@@ -434,11 +436,8 @@
/// in, or NULL if this address doesn't belong in a module, or
/// isn't resolved yet.
//------------------------------------------------------------------
- Module *
- GetModulePtr () const;
-
lldb::ModuleSP
- GetModuleSP () const;
+ GetModule () const;
//------------------------------------------------------------------
/// Get const accessor for the section.
@@ -447,8 +446,8 @@
/// Returns the const lldb::Section pointer that this address is an
/// offset in, or NULL if this address is absolute.
//------------------------------------------------------------------
- const Section*
- GetSection() const { return m_section; }
+ lldb::SectionSP
+ GetSection () const { return m_section_wp.lock(); }
//------------------------------------------------------------------
/// Set accessor for the offset.
@@ -466,6 +465,13 @@
m_offset = offset;
return changed;
}
+
+ void
+ SetRawAddress (lldb::addr_t addr)
+ {
+ m_section_wp.reset();
+ m_offset = addr;
+ }
bool
Slide (int64_t offset)
@@ -487,8 +493,16 @@
/// any section.
//------------------------------------------------------------------
void
- SetSection (const Section* section) { m_section = section; }
+ SetSection (const lldb::SectionSP §ion_sp)
+ {
+ m_section_wp = section_sp;
+ }
+ void
+ ClearSection ()
+ {
+ m_section_wp.reset();
+ }
//------------------------------------------------------------------
/// Reconstruct a symbol context from an address.
///
@@ -503,7 +517,7 @@
CalculateSymbolContext (SymbolContext *sc,
uint32_t resolve_scope = lldb::eSymbolContextEverything) const;
- Module *
+ lldb::ModuleSP
CalculateSymbolContextModule () const;
CompileUnit *
@@ -525,8 +539,8 @@
//------------------------------------------------------------------
// Member variables.
//------------------------------------------------------------------
- const Section* m_section; ///< The section for the address, can be NULL.
- lldb::addr_t m_offset; ///< Offset into section if \a m_section != NULL, else the absolute address value.
+ lldb::SectionWP m_section_wp; ///< The section for the address, can be NULL.
+ lldb::addr_t m_offset; ///< Offset into section if \a m_section_wp is valid...
};
Modified: lldb/trunk/include/lldb/Core/AddressRange.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/AddressRange.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/AddressRange.h (original)
+++ lldb/trunk/include/lldb/Core/AddressRange.h Thu Feb 23 19:59:29 2012
@@ -45,7 +45,7 @@
/// @param[in] byte_size
/// The size in bytes of the address range.
//------------------------------------------------------------------
- AddressRange (const Section* section, lldb::addr_t offset, lldb::addr_t byte_size);
+ AddressRange (const lldb::SectionSP §ion, lldb::addr_t offset, lldb::addr_t byte_size);
//------------------------------------------------------------------
/// Construct with a virtual address, section list and byte size.
Modified: lldb/trunk/include/lldb/Core/Module.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Module.h (original)
+++ lldb/trunk/include/lldb/Core/Module.h Thu Feb 23 19:59:29 2012
@@ -149,7 +149,7 @@
virtual void
CalculateSymbolContext (SymbolContext* sc);
- virtual Module *
+ virtual lldb::ModuleSP
CalculateSymbolContextModule ();
void
@@ -464,6 +464,18 @@
m_platform_file = file;
}
+ const FileSpec &
+ GetSymbolFileFileSpec () const
+ {
+ return m_symfile_spec;
+ }
+
+ void
+ SetSymbolFileFileSpec (const FileSpec &file)
+ {
+ m_symfile_spec = file;
+ }
+
const TimeValue &
GetModificationTime () const;
@@ -740,6 +752,7 @@
lldb_private::UUID m_uuid; ///< Each module is assumed to have a unique identifier to help match it up to debug symbols.
FileSpec m_file; ///< The file representation on disk for this module (if there is one).
FileSpec m_platform_file;///< The path to the module on the platform on which it is being debugged
+ FileSpec m_symfile_spec; ///< If this path is valid, then this is the file that _will_ be used as the symbol file for this module
ConstString m_object_name; ///< The name an object within this module that is selected, or empty of the module is represented by \a m_file.
uint64_t m_object_offset;
lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file parser for this module as it may or may not be shared with the SymbolFile
Modified: lldb/trunk/include/lldb/Core/ModuleChild.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ModuleChild.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ModuleChild.h (original)
+++ lldb/trunk/include/lldb/Core/ModuleChild.h Thu Feb 23 19:59:29 2012
@@ -29,7 +29,7 @@
/// The module that owns the object that inherits from this
/// class.
//------------------------------------------------------------------
- ModuleChild (Module* module);
+ ModuleChild (const lldb::ModuleSP &module_sp);
//------------------------------------------------------------------
/// Copy constructor.
@@ -61,22 +61,13 @@
operator= (const ModuleChild& rhs);
//------------------------------------------------------------------
- /// Get accessor for the module pointer.
- ///
- /// @return
- /// A pointer to the module that owns this object.
- //------------------------------------------------------------------
- Module *
- GetModule ();
-
- //------------------------------------------------------------------
/// Get const accessor for the module pointer.
///
/// @return
/// A const pointer to the module that owns the object that
/// inherits from this class.
//------------------------------------------------------------------
- Module *
+ lldb::ModuleSP
GetModule () const;
//------------------------------------------------------------------
@@ -87,14 +78,14 @@
/// class.
//------------------------------------------------------------------
void
- SetModule (Module *module);
+ SetModule (const lldb::ModuleSP &module_sp);
protected:
//------------------------------------------------------------------
// Member variables
//------------------------------------------------------------------
- Module *m_module; ///< The Module that owns the object that inherits
- ///< from this class.
+ lldb::ModuleWP m_module_wp; ///< The Module that owns the object that inherits
+ ///< from this class.
};
} // namespace lldb_private
Modified: lldb/trunk/include/lldb/Core/Section.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Section.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Section.h (original)
+++ lldb/trunk/include/lldb/Core/Section.h Thu Feb 23 19:59:29 2012
@@ -34,10 +34,10 @@
~SectionList();
uint32_t
- AddSection (lldb::SectionSP& sect_sp);
+ AddSection (const lldb::SectionSP& section_sp);
uint32_t
- AddUniqueSection (lldb::SectionSP& sect_sp);
+ AddUniqueSection (const lldb::SectionSP& section_sp);
uint32_t
FindSectionIndex (const Section* sect);
@@ -58,9 +58,6 @@
FindSectionByType (lldb::SectionType sect_type, bool check_children, uint32_t start_idx = 0) const;
lldb::SectionSP
- GetSharedPointer (const Section *section, bool check_children) const;
-
- lldb::SectionSP
FindSectionContainingFileAddress (lldb::addr_t addr, uint32_t depth = UINT32_MAX) const;
lldb::SectionSP
@@ -81,7 +78,7 @@
GetNumSections (uint32_t depth) const;
bool
- ReplaceSection (lldb::user_id_t sect_id, lldb::SectionSP& sect_sp, uint32_t depth = UINT32_MAX);
+ ReplaceSection (lldb::user_id_t sect_id, const lldb::SectionSP& section_sp, uint32_t depth = UINT32_MAX);
lldb::SectionSP
GetSectionAtIndex (uint32_t idx) const;
@@ -95,32 +92,40 @@
class Section :
+ public std::tr1::enable_shared_from_this<Section>,
public ModuleChild,
public UserID,
public Flags
{
public:
- Section (
- Section *parent, // NULL for top level sections, non-NULL for child sections
- Module* module,
- lldb::user_id_t sect_id,
- const ConstString &name,
- lldb::SectionType sect_type,
- lldb::addr_t file_vm_addr,
- lldb::addr_t vm_size,
- uint64_t file_offset,
- uint64_t file_size,
- uint32_t flags);
+ // Create a root section (one that has no parent)
+ Section (const lldb::ModuleSP &module_sp,
+ lldb::user_id_t sect_id,
+ const ConstString &name,
+ lldb::SectionType sect_type,
+ lldb::addr_t file_vm_addr,
+ lldb::addr_t vm_size,
+ uint64_t file_offset,
+ uint64_t file_size,
+ uint32_t flags);
+
+ // Create a section that is a child of parent_section_sp
+ Section (const lldb::SectionSP &parent_section_sp, // NULL for top level sections, non-NULL for child sections
+ const lldb::ModuleSP &module_sp,
+ lldb::user_id_t sect_id,
+ const ConstString &name,
+ lldb::SectionType sect_type,
+ lldb::addr_t file_vm_addr,
+ lldb::addr_t vm_size,
+ uint64_t file_offset,
+ uint64_t file_size,
+ uint32_t flags);
~Section ();
static int
Compare (const Section& a, const Section& b);
- // Get a valid shared pointer to this section object
- lldb::SectionSP
- GetSharedPointer() const;
-
bool
ContainsFileAddress (lldb::addr_t vm_addr) const;
@@ -176,15 +181,7 @@
GetFileAddress () const;
lldb::addr_t
- GetOffset () const
- {
- // This section has a parent which means m_file_addr is an offset.
- if (m_parent)
- return m_file_addr;
-
- // This section has no parent, so there is no offset to be had
- return 0;
- }
+ GetOffset () const;
lldb::addr_t
@@ -226,9 +223,6 @@
bool
IsDescendant (const Section *section);
- ConstString&
- GetName ();
-
const ConstString&
GetName () const;
@@ -236,15 +230,15 @@
Slide (lldb::addr_t slide_amount, bool slide_children);
void
- SetLinkedLocation (const Section *linked_section, uint64_t linked_offset);
+ SetLinkedLocation (const lldb::SectionSP &linked_section_sp, uint64_t linked_offset);
bool
ContainsLinkedFileAddress (lldb::addr_t vm_addr) const;
- const Section *
+ lldb::SectionSP
GetLinkedSection () const
{
- return m_linked_section;
+ return m_linked_section_wp.lock();
}
uint64_t
@@ -262,9 +256,15 @@
return m_type;
}
+ lldb::SectionSP
+ GetParent () const
+ {
+ return m_parent_wp.lock();
+ }
+
protected:
- Section * m_parent; // Parent section or NULL if no parent.
+ lldb::SectionWP m_parent_wp; // Weak pointer to parent section
ConstString m_name; // Name of this section
lldb::SectionType m_type; // The type of this section
lldb::addr_t m_file_addr; // The absolute file virtual address range of this section if m_parent == NULL,
@@ -278,7 +278,7 @@
// that are contained in the address range for this section, but do not produce
// hits unless the children contain the address.
m_encrypted:1; // Set to true if the contents are encrypted
- const Section * m_linked_section;
+ lldb::SectionWP m_linked_section_wp;
uint64_t m_linked_offset;
private:
DISALLOW_COPY_AND_ASSIGN (Section);
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Thu Feb 23 19:59:29 2012
@@ -621,12 +621,12 @@
// Return the module associated with this value object in case the
// value is from an executable file and might have its data in
// sections of the file. This can be used for variables.
- virtual Module *
+ virtual lldb::ModuleSP
GetModule()
{
if (m_parent)
return m_parent->GetModule();
- return NULL;
+ return lldb::ModuleSP();
}
virtual bool
Modified: lldb/trunk/include/lldb/Core/ValueObjectMemory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectMemory.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectMemory.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectMemory.h Thu Feb 23 19:59:29 2012
@@ -56,7 +56,7 @@
virtual bool
IsInScope ();
- virtual Module*
+ virtual lldb::ModuleSP
GetModule();
protected:
Modified: lldb/trunk/include/lldb/Core/ValueObjectVariable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObjectVariable.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObjectVariable.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObjectVariable.h Thu Feb 23 19:59:29 2012
@@ -46,7 +46,7 @@
virtual bool
IsInScope ();
- virtual Module*
+ virtual lldb::ModuleSP
GetModule();
virtual SymbolContextScope *
Modified: lldb/trunk/include/lldb/Symbol/Block.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Block.h (original)
+++ lldb/trunk/include/lldb/Symbol/Block.h Thu Feb 23 19:59:29 2012
@@ -112,7 +112,7 @@
virtual void
CalculateSymbolContext(SymbolContext* sc);
- virtual Module *
+ virtual lldb::ModuleSP
CalculateSymbolContextModule ();
virtual CompileUnit *
Modified: lldb/trunk/include/lldb/Symbol/CompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/CompileUnit.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/CompileUnit.h (original)
+++ lldb/trunk/include/lldb/Symbol/CompileUnit.h Thu Feb 23 19:59:29 2012
@@ -68,7 +68,7 @@
///
/// @see lldb::LanguageType
//------------------------------------------------------------------
- CompileUnit(Module *module, void *user_data, const char *pathname, lldb::user_id_t uid, lldb::LanguageType language);
+ CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, lldb::user_id_t uid, lldb::LanguageType language);
//------------------------------------------------------------------
/// Construct with a module, file spec, UID and language.
@@ -100,7 +100,7 @@
///
/// @see lldb::LanguageType
//------------------------------------------------------------------
- CompileUnit(Module *module, void *user_data, const FileSpec &file_spec, lldb::user_id_t uid, lldb::LanguageType language);
+ CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &file_spec, lldb::user_id_t uid, lldb::LanguageType language);
//------------------------------------------------------------------
/// Destructor
@@ -127,7 +127,7 @@
virtual void
CalculateSymbolContext(SymbolContext* sc);
- virtual Module *
+ virtual lldb::ModuleSP
CalculateSymbolContextModule ();
virtual CompileUnit *
Modified: lldb/trunk/include/lldb/Symbol/Function.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Function.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Function.h (original)
+++ lldb/trunk/include/lldb/Symbol/Function.h Thu Feb 23 19:59:29 2012
@@ -422,7 +422,7 @@
virtual void
CalculateSymbolContext(SymbolContext* sc);
- virtual Module *
+ virtual lldb::ModuleSP
CalculateSymbolContextModule ();
virtual CompileUnit *
Modified: lldb/trunk/include/lldb/Symbol/LineEntry.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/LineEntry.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/LineEntry.h (original)
+++ lldb/trunk/include/lldb/Symbol/LineEntry.h Thu Feb 23 19:59:29 2012
@@ -31,7 +31,7 @@
LineEntry
(
- Section *section,
+ const lldb::SectionSP §ion_sp,
lldb::addr_t section_offset,
lldb::addr_t byte_size,
const FileSpec &file,
Modified: lldb/trunk/include/lldb/Symbol/LineTable.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/LineTable.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/LineTable.h (original)
+++ lldb/trunk/include/lldb/Symbol/LineTable.h Thu Feb 23 19:59:29 2012
@@ -55,7 +55,7 @@
// Called when you can guarantee the addresses are in increasing order
void
- AppendLineEntry (lldb::SectionSP& section_sp,
+ AppendLineEntry (const lldb::SectionSP& section_sp,
lldb::addr_t section_offset,
uint32_t line,
uint16_t column,
@@ -68,7 +68,7 @@
// Called when you can't guarantee the addresses are in increasing order
void
- InsertLineEntry (lldb::SectionSP& section_sp,
+ InsertLineEntry (const lldb::SectionSP& section_sp,
lldb::addr_t section_offset,
uint32_t line,
uint16_t column,
Modified: lldb/trunk/include/lldb/Symbol/ObjectContainer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectContainer.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ObjectContainer.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectContainer.h Thu Feb 23 19:59:29 2012
@@ -47,12 +47,12 @@
/// supplied upon construction. The at an offset within a file for
/// objects that contain more than one architecture or object.
//------------------------------------------------------------------
- ObjectContainer (Module* module,
+ ObjectContainer (const lldb::ModuleSP &module_sp,
const FileSpec *file,
lldb::addr_t file_offset,
lldb::addr_t file_size,
lldb::DataBufferSP& file_data_sp) :
- ModuleChild (module),
+ ModuleChild (module_sp),
m_file (), // This file can be different than the module's file spec
m_offset (file_offset),
m_length (file_size),
Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Thu Feb 23 19:59:29 2012
@@ -86,13 +86,13 @@
/// supplied upon construction. The at an offset within a file for
/// objects that contain more than one architecture or object.
//------------------------------------------------------------------
- ObjectFile (Module* module,
+ ObjectFile (const lldb::ModuleSP &module_sp,
const FileSpec *file_spec_ptr,
lldb::addr_t offset,
lldb::addr_t length,
lldb::DataBufferSP& headerDataSP);
- ObjectFile (Module* module,
+ ObjectFile (const lldb::ModuleSP &module_sp,
const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr,
lldb::DataBufferSP& headerDataSP);
@@ -146,7 +146,7 @@
/// @see ObjectFile::ParseHeader()
//------------------------------------------------------------------
static lldb::ObjectFileSP
- FindPlugin (Module* module,
+ FindPlugin (const lldb::ModuleSP &module_sp,
const FileSpec* file_spec,
lldb::addr_t file_offset,
lldb::addr_t file_size,
@@ -170,7 +170,7 @@
/// The address of the header for the object file in memory.
//------------------------------------------------------------------
static lldb::ObjectFileSP
- FindPlugin (Module* module,
+ FindPlugin (const lldb::ModuleSP &module_sp,
const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr,
lldb::DataBufferSP &file_data_sp);
Modified: lldb/trunk/include/lldb/Symbol/Symbol.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symbol.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Symbol.h (original)
+++ lldb/trunk/include/lldb/Symbol/Symbol.h Thu Feb 23 19:59:29 2012
@@ -35,7 +35,7 @@
bool is_debug,
bool is_trampoline,
bool is_artificial,
- const Section* section,
+ const lldb::SectionSP §ion_sp,
lldb::addr_t value,
uint32_t size,
uint32_t flags);
@@ -186,7 +186,7 @@
virtual void
CalculateSymbolContext (SymbolContext *sc);
- virtual Module *
+ virtual lldb::ModuleSP
CalculateSymbolContextModule ();
virtual Symbol *
Modified: lldb/trunk/include/lldb/Symbol/SymbolContextScope.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolContextScope.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolContextScope.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolContextScope.h Thu Feb 23 19:59:29 2012
@@ -88,10 +88,10 @@
CalculateSymbolContext (SymbolContext *sc) = 0;
- virtual Module *
+ virtual lldb::ModuleSP
CalculateSymbolContextModule ()
{
- return NULL;
+ return lldb::ModuleSP();
}
virtual CompileUnit *
Modified: lldb/trunk/include/lldb/Symbol/SymbolVendor.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolVendor.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/SymbolVendor.h (original)
+++ lldb/trunk/include/lldb/Symbol/SymbolVendor.h Thu Feb 23 19:59:29 2012
@@ -47,12 +47,12 @@
static SymbolVendor*
- FindPlugin (Module* module);
+ FindPlugin (const lldb::ModuleSP &module_sp);
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- SymbolVendor(Module *module);
+ SymbolVendor(const lldb::ModuleSP &module_sp);
virtual
~SymbolVendor();
Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Thu Feb 23 19:59:29 2012
@@ -271,6 +271,7 @@
typedef std::tr1::shared_ptr<lldb_private::RegisterContext> RegisterContextSP;
typedef std::tr1::shared_ptr<lldb_private::RegularExpression> RegularExpressionSP;
typedef std::tr1::shared_ptr<lldb_private::Section> SectionSP;
+ typedef std::tr1::weak_ptr<lldb_private::Section> SectionWP;
typedef std::tr1::shared_ptr<lldb_private::SearchFilter> SearchFilterSP;
#ifndef LLDB_DISABLE_PYTHON
typedef std::tr1::shared_ptr<lldb_private::ScriptSummaryFormat> ScriptSummaryFormatSP;
Modified: lldb/trunk/include/lldb/lldb-private-interfaces.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-private-interfaces.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-private-interfaces.h (original)
+++ lldb/trunk/include/lldb/lldb-private-interfaces.h Thu Feb 23 19:59:29 2012
@@ -19,9 +19,9 @@
typedef lldb::ABISP (*ABICreateInstance) (const ArchSpec &arch);
typedef Disassembler* (*DisassemblerCreateInstance) (const ArchSpec &arch);
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 ObjectContainer* (*ObjectContainerCreateInstance) (const lldb::ModuleSP &module_sp, lldb::DataBufferSP& dataSP, const FileSpec *file, lldb::addr_t offset, lldb::addr_t length);
+ typedef ObjectFile* (*ObjectFileCreateInstance) (const lldb::ModuleSP &module_sp, lldb::DataBufferSP& dataSP, const FileSpec* file, lldb::addr_t offset, lldb::addr_t length);
+ typedef ObjectFile* (*ObjectFileCreateMemoryInstance) (const lldb::ModuleSP &module_sp, 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);
@@ -29,7 +29,7 @@
typedef Platform* (*PlatformCreateInstance) ();
typedef lldb::ProcessSP (*ProcessCreateInstance) (Target &target, Listener &listener, const FileSpec *crash_file_path);
typedef SymbolFile* (*SymbolFileCreateInstance) (ObjectFile* obj_file);
- typedef SymbolVendor* (*SymbolVendorCreateInstance) (Module *module); // Module can be NULL for default system symbol vendor
+ typedef SymbolVendor* (*SymbolVendorCreateInstance) (const lldb::ModuleSP &module_sp); // Module can be NULL for default system symbol vendor
typedef bool (*BreakpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t break_id, lldb::user_id_t break_loc_id);
typedef bool (*WatchpointHitCallback) (void *baton, StoppointCallbackContext *context, lldb::user_id_t watch_id, uint32_t type);
typedef ThreadPlan * (*ThreadPlanShouldStopHereCallback) (ThreadPlan *current_plan, Flags &flags, void *baton);
Modified: lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme (original)
+++ lldb/trunk/lldb.xcodeproj/xcshareddata/xcschemes/lldb-tool.xcscheme Thu Feb 23 19:59:29 2012
@@ -100,6 +100,12 @@
ReferencedContainer = "container:lldb.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
+ <CommandLineArguments>
+ <CommandLineArgument
+ argument = "/private/tmp/a.out"
+ isEnabled = "YES">
+ </CommandLineArgument>
+ </CommandLineArguments>
<EnvironmentVariables>
<EnvironmentVariable
key = "LLDB_LAUNCH_FLAG_DISABLE_ASLR"
Modified: lldb/trunk/source/API/SBAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBAddress.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/API/SBAddress.cpp (original)
+++ lldb/trunk/source/API/SBAddress.cpp Thu Feb 23 19:59:29 2012
@@ -32,7 +32,7 @@
}
AddressImpl (const Address &addr) :
- m_module_sp (addr.GetModuleSP()),
+ m_module_sp (addr.GetModule()),
m_address (addr)
{
}
@@ -105,7 +105,7 @@
SBAddress::SBAddress (lldb::SBSection section, lldb::addr_t offset) :
- m_opaque_ap(new AddressImpl (Address(section.GetSection(), offset)))
+ m_opaque_ap(new AddressImpl (Address(section.GetSP(), offset)))
{
}
@@ -151,7 +151,7 @@
SBAddress::SetAddress (lldb::SBSection section, lldb::addr_t offset)
{
Address &addr = ref();
- addr.SetSection (section.GetSection());
+ addr.SetSection (section.GetSP());
addr.SetOffset (offset);
}
@@ -241,7 +241,7 @@
{
lldb::SBSection sb_section;
if (m_opaque_ap.get())
- sb_section.SetSection(m_opaque_ap->GetAddress().GetSection());
+ sb_section.SetSP (m_opaque_ap->GetAddress().GetSection());
return sb_section;
}
Modified: lldb/trunk/source/API/SBBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBBreakpoint.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/API/SBBreakpoint.cpp (original)
+++ lldb/trunk/source/API/SBBreakpoint.cpp Thu Feb 23 19:59:29 2012
@@ -151,8 +151,7 @@
Target &target = m_opaque_sp->GetTarget();
if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false)
{
- address.SetSection (NULL);
- address.SetOffset (vm_addr);
+ address.SetRawAddress (vm_addr);
}
sb_bp_location.SetLocation (m_opaque_sp->FindLocationByAddress (address));
}
@@ -172,8 +171,7 @@
Target &target = m_opaque_sp->GetTarget();
if (target.GetSectionLoadList().ResolveLoadAddress (vm_addr, address) == false)
{
- address.SetSection (NULL);
- address.SetOffset (vm_addr);
+ address.SetRawAddress (vm_addr);
}
break_id = m_opaque_sp->FindLocationIDByAddress (address);
}
Modified: lldb/trunk/source/API/SBFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFunction.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFunction.cpp (original)
+++ lldb/trunk/source/API/SBFunction.cpp Thu Feb 23 19:59:29 2012
@@ -134,7 +134,7 @@
target_sp->CalculateExecutionContext (exe_ctx);
exe_ctx.SetProcessSP(target_sp->GetProcessSP());
}
- ModuleSP module_sp = m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModuleSP();
+ ModuleSP module_sp (m_opaque_ptr->GetAddressRange().GetBaseAddress().GetModule());
if (module_sp)
{
sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module_sp->GetArchitecture(),
Modified: lldb/trunk/source/API/SBModule.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBModule.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/API/SBModule.cpp (original)
+++ lldb/trunk/source/API/SBModule.cpp Thu Feb 23 19:59:29 2012
@@ -331,7 +331,7 @@
SectionList *section_list = obj_file->GetSectionList ();
if (section_list)
- sb_section.SetSection(section_list->GetSectionAtIndex (idx).get());
+ sb_section.SetSP(section_list->GetSectionAtIndex (idx));
}
}
return sb_section;
@@ -467,7 +467,7 @@
SectionSP section_sp (section_list->FindSectionByName(const_sect_name));
if (section_sp)
{
- sb_section.SetSection(section_sp.get());
+ sb_section.SetSP (section_sp);
}
}
}
Modified: lldb/trunk/source/API/SBSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSection.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSection.cpp (original)
+++ lldb/trunk/source/API/SBSection.cpp Thu Feb 23 19:59:29 2012
@@ -16,106 +16,34 @@
#include "lldb/Core/Section.h"
#include "lldb/Core/StreamString.h"
-namespace lldb_private
-{
- // We need a section implementation to hold onto a reference to the module
- // since if the module goes away and we have anyone still holding onto a
- // SBSection object, we could crash.
- class SectionImpl
- {
- public:
- SectionImpl (const lldb_private::Section *section = NULL) :
- m_module_sp (),
- m_section (section)
- {
- if (section)
- m_module_sp = section->GetModule()->shared_from_this();
- }
-
- SectionImpl (const SectionImpl &rhs) :
- m_module_sp (rhs.m_module_sp),
- m_section (rhs.m_section)
- {
- }
-
- bool
- IsValid () const
- {
- return m_section != NULL;
- }
-
- void
- operator = (const SectionImpl &rhs)
- {
- m_module_sp = rhs.m_module_sp;
- m_section = rhs.m_section;
- }
-
- void
- operator =(const lldb_private::Section *section)
- {
- m_section = section;
- if (section)
- m_module_sp.reset(section->GetModule());
- else
- m_module_sp.reset();
- }
-
- const lldb_private::Section *
- GetSection () const
- {
- return m_section;
- }
-
- Module *
- GetModule()
- {
- return m_module_sp.get();
- }
-
- const lldb::ModuleSP &
- GetModuleSP() const
- {
- return m_module_sp;
- }
- protected:
- lldb::ModuleSP m_module_sp;
- const lldb_private::Section *m_section;
- };
-}
using namespace lldb;
using namespace lldb_private;
SBSection::SBSection () :
- m_opaque_ap ()
+ m_opaque_wp ()
{
}
SBSection::SBSection (const SBSection &rhs) :
- m_opaque_ap ()
+ m_opaque_wp (rhs.m_opaque_wp)
{
- if (rhs.IsValid())
- m_opaque_ap.reset (new SectionImpl (*rhs.m_opaque_ap));
}
-SBSection::SBSection (const lldb_private::Section *section) :
- m_opaque_ap ()
+SBSection::SBSection (const lldb::SectionSP §ion_sp) :
+ m_opaque_wp () // Don't init with section_sp otherwise this will throw if section_sp doesn't contain a valid Section *
{
- if (section)
- m_opaque_ap.reset (new SectionImpl(section));
+ if (section_sp)
+ m_opaque_wp = section_sp;
}
const SBSection &
SBSection::operator = (const SBSection &rhs)
{
- if (this != &rhs && rhs.IsValid())
- m_opaque_ap.reset (new SectionImpl(*rhs.m_opaque_ap));
- else
- m_opaque_ap.reset ();
+ m_opaque_wp = rhs.m_opaque_wp;
return *this;
}
@@ -126,14 +54,16 @@
bool
SBSection::IsValid () const
{
- return m_opaque_ap.get() != NULL && m_opaque_ap->IsValid();
+ SectionSP section_sp (GetSP());
+ return section_sp && section_sp->GetModule().get() != NULL;
}
const char *
SBSection::GetName ()
{
- if (IsValid())
- return m_opaque_ap->GetSection()->GetName().GetCString();
+ SectionSP section_sp (GetSP());
+ if (section_sp)
+ return section_sp->GetName().GetCString();
return NULL;
}
@@ -142,10 +72,14 @@
SBSection::FindSubSection (const char *sect_name)
{
lldb::SBSection sb_section;
- if (sect_name && IsValid())
+ if (sect_name)
{
- ConstString const_sect_name(sect_name);
- sb_section.SetSection(m_opaque_ap->GetSection()->GetChildren ().FindSectionByName(const_sect_name).get());
+ SectionSP section_sp (GetSP());
+ if (section_sp)
+ {
+ ConstString const_sect_name(sect_name);
+ sb_section.SetSP(section_sp->GetChildren ().FindSectionByName(const_sect_name));
+ }
}
return sb_section;
}
@@ -153,8 +87,9 @@
size_t
SBSection::GetNumSubSections ()
{
- if (IsValid())
- return m_opaque_ap->GetSection()->GetChildren ().GetSize();
+ SectionSP section_sp (GetSP());
+ if (section_sp)
+ return section_sp->GetChildren ().GetSize();
return 0;
}
@@ -162,79 +97,66 @@
SBSection::GetSubSectionAtIndex (size_t idx)
{
lldb::SBSection sb_section;
- if (IsValid())
- sb_section.SetSection(m_opaque_ap->GetSection()->GetChildren ().GetSectionAtIndex(idx).get());
+ SectionSP section_sp (GetSP());
+ if (section_sp)
+ sb_section.SetSP (section_sp->GetChildren ().GetSectionAtIndex(idx));
return sb_section;
}
-const lldb_private::Section *
-SBSection::GetSection()
+lldb::SectionSP
+SBSection::GetSP() const
{
- if (m_opaque_ap.get())
- return m_opaque_ap->GetSection();
- return NULL;
+ return m_opaque_wp.lock();
}
void
-SBSection::SetSection (const lldb_private::Section *section)
+SBSection::SetSP(const lldb::SectionSP §ion_sp)
{
- m_opaque_ap.reset (new SectionImpl(section));
+ m_opaque_wp = section_sp;
}
-
-
-
lldb::addr_t
SBSection::GetFileAddress ()
{
lldb::addr_t file_addr = LLDB_INVALID_ADDRESS;
- if (IsValid())
- return m_opaque_ap->GetSection()->GetFileAddress();
+ SectionSP section_sp (GetSP());
+ if (section_sp)
+ return section_sp->GetFileAddress();
return file_addr;
}
lldb::addr_t
SBSection::GetByteSize ()
{
- if (IsValid())
- {
- const Section *section = m_opaque_ap->GetSection();
- if (section)
- return section->GetByteSize();
- }
+ SectionSP section_sp (GetSP());
+ if (section_sp)
+ return section_sp->GetByteSize();
return 0;
}
uint64_t
SBSection::GetFileOffset ()
{
- if (IsValid())
+ SectionSP section_sp (GetSP());
+ if (section_sp)
{
- const Section *section = m_opaque_ap->GetSection();
- if (section)
+ ModuleSP module_sp (section_sp->GetModule());
+ if (module_sp)
{
- Module *module = m_opaque_ap->GetModule();
- if (module)
- {
- ObjectFile *objfile = module->GetObjectFile();
- if (objfile)
- return objfile->GetOffset() + section->GetFileOffset();
- }
- return section->GetFileOffset();
+ ObjectFile *objfile = module_sp->GetObjectFile();
+ if (objfile)
+ return objfile->GetOffset() + section_sp->GetFileOffset();
}
}
- return 0;
+ return UINT64_MAX;
}
uint64_t
SBSection::GetFileByteSize ()
{
- if (IsValid())
- {
- const Section *section = m_opaque_ap->GetSection();
- if (section)
- return section->GetFileSize();
- }
+ SectionSP section_sp (GetSP());
+ if (section_sp)
+ return section_sp->GetFileSize();
return 0;
}
@@ -248,40 +170,37 @@
SBSection::GetSectionData (uint64_t offset, uint64_t size)
{
SBData sb_data;
- if (IsValid())
+ SectionSP section_sp (GetSP());
+ if (section_sp)
{
- const Section *section = m_opaque_ap->GetSection();
- if (section)
+ const uint64_t sect_file_size = section_sp->GetFileSize();
+ if (sect_file_size > 0)
{
- const uint64_t sect_file_size = section->GetFileSize();
- if (sect_file_size > 0)
+ ModuleSP module_sp (section_sp->GetModule());
+ if (module_sp)
{
- Module *module = m_opaque_ap->GetModule();
- if (module)
+ ObjectFile *objfile = module_sp->GetObjectFile();
+ if (objfile)
{
- ObjectFile *objfile = module->GetObjectFile();
- if (objfile)
+ const uint64_t sect_file_offset = objfile->GetOffset() + section_sp->GetFileOffset();
+ const uint64_t file_offset = sect_file_offset + offset;
+ uint64_t file_size = size;
+ if (file_size == UINT64_MAX)
{
- const uint64_t sect_file_offset = objfile->GetOffset() + section->GetFileOffset();
- const uint64_t file_offset = sect_file_offset + offset;
- uint64_t file_size = size;
- if (file_size == UINT64_MAX)
- {
- file_size = section->GetByteSize();
- if (file_size > offset)
- file_size -= offset;
- else
- file_size = 0;
- }
- DataBufferSP data_buffer_sp (objfile->GetFileSpec().ReadFileContents (file_offset, file_size));
- if (data_buffer_sp && data_buffer_sp->GetByteSize() > 0)
- {
- DataExtractorSP data_extractor_sp (new DataExtractor (data_buffer_sp,
- objfile->GetByteOrder(),
- objfile->GetAddressByteSize()));
-
- sb_data.SetOpaque (data_extractor_sp);
- }
+ file_size = section_sp->GetByteSize();
+ if (file_size > offset)
+ file_size -= offset;
+ else
+ file_size = 0;
+ }
+ DataBufferSP data_buffer_sp (objfile->GetFileSpec().ReadFileContents (file_offset, file_size));
+ if (data_buffer_sp && data_buffer_sp->GetByteSize() > 0)
+ {
+ DataExtractorSP data_extractor_sp (new DataExtractor (data_buffer_sp,
+ objfile->GetByteOrder(),
+ objfile->GetAddressByteSize()));
+
+ sb_data.SetOpaque (data_extractor_sp);
}
}
}
@@ -293,12 +212,9 @@
SectionType
SBSection::GetSectionType ()
{
- if (m_opaque_ap.get())
- {
- const Section *section = m_opaque_ap->GetSection();
- if (section)
- return section->GetType();
- }
+ SectionSP section_sp (GetSP());
+ if (section_sp.get())
+ return section_sp->GetType();
return eSectionTypeInvalid;
}
@@ -306,21 +222,19 @@
bool
SBSection::operator == (const SBSection &rhs)
{
- SectionImpl *lhs_ptr = m_opaque_ap.get();
- SectionImpl *rhs_ptr = rhs.m_opaque_ap.get();
- if (lhs_ptr && rhs_ptr)
- return lhs_ptr->GetSection() == rhs_ptr->GetSection();
+ SectionSP lhs_section_sp (GetSP());
+ SectionSP rhs_section_sp (rhs.GetSP());
+ if (lhs_section_sp && rhs_section_sp)
+ return lhs_section_sp == rhs_section_sp;
return false;
}
bool
SBSection::operator != (const SBSection &rhs)
{
- SectionImpl *lhs_ptr = m_opaque_ap.get();
- SectionImpl *rhs_ptr = rhs.m_opaque_ap.get();
- if (lhs_ptr && rhs_ptr)
- return lhs_ptr->GetSection() != rhs_ptr->GetSection();
- return false;
+ SectionSP lhs_section_sp (GetSP());
+ SectionSP rhs_section_sp (rhs.GetSP());
+ return lhs_section_sp != rhs_section_sp;
}
bool
@@ -328,12 +242,12 @@
{
Stream &strm = description.ref();
- if (IsValid())
+ SectionSP section_sp (GetSP());
+ if (section_sp)
{
- const Section *section = m_opaque_ap->GetSection();
- const addr_t file_addr = section->GetFileAddress();
- strm.Printf ("[0x%16.16llx-0x%16.16llx) ", file_addr, file_addr + section->GetByteSize());
- section->DumpName(&strm);
+ const addr_t file_addr = section_sp->GetFileAddress();
+ strm.Printf ("[0x%16.16llx-0x%16.16llx) ", file_addr, file_addr + section_sp->GetByteSize());
+ section_sp->DumpName(&strm);
}
else
{
Modified: lldb/trunk/source/API/SBSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBSymbol.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/API/SBSymbol.cpp (original)
+++ lldb/trunk/source/API/SBSymbol.cpp Thu Feb 23 19:59:29 2012
@@ -132,7 +132,7 @@
const AddressRange *symbol_range = m_opaque_ptr->GetAddressRangePtr();
if (symbol_range)
{
- ModuleSP module_sp = symbol_range->GetBaseAddress().GetModuleSP();
+ ModuleSP module_sp (symbol_range->GetBaseAddress().GetModule());
if (module_sp)
{
sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module_sp->GetArchitecture (),
Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Thu Feb 23 19:59:29 2012
@@ -557,8 +557,7 @@
// We have a load address that isn't in a section, just return an address
// with the offset filled in (the address) and the section set to NULL
- addr.SetSection(NULL);
- addr.SetOffset(vm_addr);
+ addr.SetRawAddress(vm_addr);
return sb_addr;
}
@@ -1411,7 +1410,7 @@
}
else
{
- target_sp->GetSectionLoadList().SetSectionLoadAddress (section.GetSection(), section_base_addr);
+ target_sp->GetSectionLoadList().SetSectionLoadAddress (section.GetSP().get(), section_base_addr);
}
}
else
@@ -1435,7 +1434,7 @@
}
else
{
- target_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSection());
+ target_sp->GetSectionLoadList().SetSectionUnloaded (section.GetSP().get());
}
}
else
Modified: lldb/trunk/source/API/SBThread.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBThread.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/API/SBThread.cpp (original)
+++ lldb/trunk/source/API/SBThread.cpp Thu Feb 23 19:59:29 2012
@@ -635,7 +635,7 @@
bool abort_other_plans = true;
bool stop_other_threads = true;
- Address target_addr (NULL, addr);
+ Address target_addr (addr);
Thread *thread = exe_ctx.GetThreadPtr();
Process *process = exe_ctx.GetProcessPtr();
Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Thu Feb 23 19:59:29 2012
@@ -1221,13 +1221,13 @@
value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
if (addr_type == eAddressTypeFile)
{
- Module* module = value_sp->GetModule();
- if (!module)
+ ModuleSP module_sp (value_sp->GetModule());
+ if (!module_sp)
value = LLDB_INVALID_ADDRESS;
else
{
Address addr;
- module->ResolveFileAddress(value, addr);
+ module_sp->ResolveFileAddress(value, addr);
value = addr.GetLoadAddress(target_sp.get());
}
}
@@ -1259,9 +1259,9 @@
value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
if (addr_type == eAddressTypeFile)
{
- Module* module = value_sp->GetModule();
- if (module)
- module->ResolveFileAddress(value, addr);
+ ModuleSP module_sp (value_sp->GetModule());
+ if (module_sp)
+ module_sp->ResolveFileAddress(value, addr);
}
else if (addr_type == eAddressTypeLoad)
{
Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Breakpoint.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Breakpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Breakpoint.cpp Thu Feb 23 19:59:29 2012
@@ -351,8 +351,8 @@
BreakpointLocationSP break_loc = m_locations.GetByIndex(loc_idx);
if (!break_loc->IsEnabled())
continue;
- const Section *section = break_loc->GetAddress().GetSection();
- if (section == NULL || section->GetModule() == module_sp.get())
+ SectionSP section_sp (break_loc->GetAddress().GetSection());
+ if (!section_sp || section_sp->GetModule() == module_sp)
{
if (!seen)
seen = true;
@@ -419,23 +419,25 @@
ModuleSP module_sp (module_list.GetModuleAtIndex (i));
if (m_filter_sp->ModulePasses (module_sp))
{
- const size_t num_locs = m_locations.GetSize();
- for (size_t loc_idx = 0; loc_idx < num_locs; ++loc_idx)
+ size_t loc_idx = 0;
+ while (loc_idx < m_locations.GetSize())
{
- BreakpointLocationSP break_loc = m_locations.GetByIndex(loc_idx);
- const Section *section = break_loc->GetAddress().GetSection();
- if (section && section->GetModule() == module_sp.get())
+ BreakpointLocationSP break_loc_sp (m_locations.GetByIndex(loc_idx));
+ SectionSP section_sp (break_loc_sp->GetAddress().GetSection());
+ if (section_sp && section_sp->GetModule() == module_sp)
{
// Remove this breakpoint since the shared library is
// unloaded, but keep the breakpoint location around
// so we always get complete hit count and breakpoint
// lifetime info
- break_loc->ClearBreakpointSite();
+ break_loc_sp->ClearBreakpointSite();
if (removed_locations_event)
{
- removed_locations_event->GetBreakpointLocationCollection().Add(break_loc);
+ removed_locations_event->GetBreakpointLocationCollection().Add(break_loc_sp);
}
+ //m_locations.RemoveLocation (break_loc_sp);
}
+ ++loc_idx;
}
}
}
Modified: lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp Thu Feb 23 19:59:29 2012
@@ -25,7 +25,8 @@
m_address_to_location (),
m_mutex (Mutex::eMutexTypeRecursive),
m_new_location_recorder (NULL),
- m_owner (owner)
+ m_owner (owner),
+ m_next_id (0)
{
}
@@ -38,7 +39,7 @@
{
Mutex::Locker locker (m_mutex);
// The location ID is just the size of the location list + 1
- lldb::break_id_t bp_loc_id = m_locations.size() + 1;
+ lldb::break_id_t bp_loc_id = ++m_next_id;
BreakpointLocationSP bp_loc_sp (new BreakpointLocation (bp_loc_id, m_owner, addr));
m_locations.push_back (bp_loc_sp);
m_address_to_location[addr] = bp_loc_sp;
@@ -98,8 +99,8 @@
for (pos = m_locations.begin(); pos != end; ++pos)
{
BreakpointLocationSP break_loc = (*pos);
- const Section *section = break_loc->GetAddress().GetSection();
- if (section && section->GetModule() == module)
+ SectionSP section_sp (break_loc->GetAddress().GetSection());
+ if (section_sp && section_sp->GetModule().get() == module)
{
bp_loc_list.Add (break_loc);
}
@@ -245,6 +246,29 @@
return bp_loc_sp;
}
+bool
+BreakpointLocationList::RemoveLocation (const lldb::BreakpointLocationSP &bp_loc_sp)
+{
+ if (bp_loc_sp)
+ {
+ Mutex::Locker locker (m_mutex);
+
+ m_address_to_location.erase (bp_loc_sp->GetAddress());
+
+ collection::iterator pos, end = m_locations.end();
+ for (pos = m_locations.begin(); pos != end; ++pos)
+ {
+ if ((*pos).get() == bp_loc_sp.get())
+ {
+ m_locations.erase (pos);
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+
void
BreakpointLocationList::StartRecordingNewLocations (BreakpointLocationCollection &new_locations)
Modified: lldb/trunk/source/Commands/CommandObjectArgs.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectArgs.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectArgs.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectArgs.cpp Thu Feb 23 19:59:29 2012
@@ -148,15 +148,15 @@
return false;
}
- Module *thread_module = thread_cur_frame->GetFrameCodeAddress ().GetModulePtr ();
- if (!thread_module)
+ ModuleSP thread_module_sp (thread_cur_frame->GetFrameCodeAddress ().GetModule());
+ if (!thread_module_sp)
{
result.AppendError ("The PC has no associated module.");
result.SetStatus (eReturnStatusFailed);
return false;
}
- ClangASTContext &ast_context = thread_module->GetClangASTContext();
+ ClangASTContext &ast_context = thread_module_sp->GetClangASTContext();
ValueList value_list;
Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Thu Feb 23 19:59:29 2012
@@ -595,7 +595,7 @@
if (!clang_ast_type.GetOpaqueQualType())
{
data_sp.reset (new DataBufferHeap (total_byte_size, '\0'));
- Address address(NULL, addr);
+ Address address(addr, NULL);
bytes_read = target->ReadMemory(address, false, data_sp->GetBytes (), data_sp->GetByteSize(), error);
if (bytes_read == 0)
{
@@ -677,7 +677,7 @@
for (uint32_t i = 0; i<item_count; ++i)
{
addr_t item_addr = addr + (i * item_byte_size);
- Address address (NULL, item_addr);
+ Address address (item_addr);
StreamString name_strm;
name_strm.Printf ("0x%llx", item_addr);
ValueObjectSP valobj_sp (ValueObjectMemory::Create (exe_scope,
Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Thu Feb 23 19:59:29 2012
@@ -1361,16 +1361,13 @@
}
static bool
-LookupAddressInModule
-(
- CommandInterpreter &interpreter,
- Stream &strm,
- Module *module,
- uint32_t resolve_mask,
- lldb::addr_t raw_addr,
- lldb::addr_t offset,
- bool verbose
- )
+LookupAddressInModule (CommandInterpreter &interpreter,
+ Stream &strm,
+ Module *module,
+ uint32_t resolve_mask,
+ lldb::addr_t raw_addr,
+ lldb::addr_t offset,
+ bool verbose)
{
if (module)
{
@@ -1382,7 +1379,7 @@
{
if (!target->GetSectionLoadList().ResolveLoadAddress (addr, so_addr))
return false;
- else if (so_addr.GetModulePtr() != module)
+ else if (so_addr.GetModule().get() != module)
return false;
}
else
@@ -2821,10 +2818,10 @@
Address module_address;
if (module_address.SetLoadAddress(m_options.m_module_addr, target))
{
- Module *module = module_address.GetModulePtr();
- if (module)
+ ModuleSP module_sp (module_address.GetModule());
+ if (module_sp)
{
- PrintModule (target, module, UINT32_MAX, 0, strm);
+ PrintModule (target, module_sp.get(), UINT32_MAX, 0, strm);
result.SetStatus (eReturnStatusSuccessFinishResult);
}
else
@@ -3511,6 +3508,205 @@
};
+
+class CommandObjectTargetSymbolsAdd : public CommandObject
+{
+public:
+ CommandObjectTargetSymbolsAdd (CommandInterpreter &interpreter) :
+ CommandObject (interpreter,
+ "target symbols add",
+ "Add a debug symbol file to one of the target's current modules.",
+ "target symbols add [<symfile>]")
+ {
+ }
+
+ virtual
+ ~CommandObjectTargetSymbolsAdd ()
+ {
+ }
+
+ virtual bool
+ Execute (Args& args,
+ CommandReturnObject &result)
+ {
+ Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
+ if (target == NULL)
+ {
+ result.AppendError ("invalid target, create a debug target using the 'target create' command");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ else
+ {
+ const size_t argc = args.GetArgumentCount();
+ if (argc == 0)
+ {
+ result.AppendError ("one or more symbol file paths must be specified");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ else
+ {
+ for (size_t i=0; i<argc; ++i)
+ {
+ const char *symfile_path = args.GetArgumentAtIndex(i);
+ if (symfile_path)
+ {
+ FileSpec symfile_spec(symfile_path, true);
+ ArchSpec arch;
+ if (symfile_spec.Exists())
+ {
+ ModuleSP symfile_module_sp (new Module (symfile_spec, target->GetArchitecture()));
+ if (symfile_module_sp)
+ {
+ // We now have a module that represents a symbol file
+ // that can be used for a module that might exist in the
+ // current target, so we need to find that module in the
+ // target
+
+ ModuleSP old_module_sp (target->GetImages().FindModule (symfile_module_sp->GetUUID()));
+ if (old_module_sp)
+ {
+ const bool can_create = false;
+ if (old_module_sp->GetSymbolVendor (can_create))
+ {
+ // The current module already has a symbol file, so we need
+ // need to unload the existing references to this module,
+ // and reload with the new one.
+
+ ModuleSP target_exe_module_sp (target->GetExecutableModule());
+ const bool adding_symbols_to_executable = target_exe_module_sp.get() == old_module_sp.get();
+ FileSpec target_module_file (old_module_sp->GetFileSpec());
+ ArchSpec target_module_arch (old_module_sp->GetArchitecture());
+
+ // Unload the old module
+ ModuleList module_list;
+ module_list.Append (old_module_sp);
+ target->ModulesDidUnload (module_list);
+
+ // Remove the module from the shared list
+ ModuleList::RemoveSharedModule (old_module_sp);
+
+ // Now create the new module and load it
+ module_list.Clear();
+ //ModuleSP new_module_sp (new Module (target_module_file, target_module_arch));
+ ModuleSP new_module_sp (target->GetSharedModule(target_module_file, target_module_arch));
+ if (new_module_sp)
+ {
+ new_module_sp->SetSymbolFileFileSpec (symfile_module_sp->GetFileSpec());
+
+ if (adding_symbols_to_executable)
+ {
+ bool get_dependent_files = true;
+ target->SetExecutableModule(new_module_sp, get_dependent_files);
+ }
+ else
+ {
+ module_list.Append (new_module_sp);
+ target->ModulesDidLoad(module_list);
+ }
+ }
+ }
+ else
+ {
+ // The module has not yet created its symbol vendor, we can just
+ // give the existing target module the symfile path to use for
+ // when it decides to create it!
+ old_module_sp->SetSymbolFileFileSpec (symfile_module_sp->GetFileSpec());
+ }
+ }
+ }
+ else
+ {
+ result.AppendError ("one or more executable image paths must be specified");
+ result.SetStatus (eReturnStatusFailed);
+ return false;
+ }
+ result.SetStatus (eReturnStatusSuccessFinishResult);
+ }
+ else
+ {
+ char resolved_symfile_path[PATH_MAX];
+ result.SetStatus (eReturnStatusFailed);
+ if (symfile_spec.GetPath (resolved_symfile_path, sizeof(resolved_symfile_path)))
+ {
+ if (strcmp (resolved_symfile_path, symfile_path) != 0)
+ {
+ result.AppendErrorWithFormat ("invalid module path '%s' with resolved path '%s'\n", symfile_path, resolved_symfile_path);
+ break;
+ }
+ }
+ result.AppendErrorWithFormat ("invalid module path '%s'\n", symfile_path);
+ break;
+ }
+ }
+ }
+ }
+ }
+ return result.Succeeded();
+ }
+
+ int
+ HandleArgumentCompletion (Args &input,
+ int &cursor_index,
+ int &cursor_char_position,
+ OptionElementVector &opt_element_vector,
+ int match_start_point,
+ int max_return_elements,
+ bool &word_complete,
+ StringList &matches)
+ {
+ std::string completion_str (input.GetArgumentAtIndex(cursor_index));
+ completion_str.erase (cursor_char_position);
+
+ CommandCompletions::InvokeCommonCompletionCallbacks (m_interpreter,
+ CommandCompletions::eDiskFileCompletion,
+ completion_str.c_str(),
+ match_start_point,
+ max_return_elements,
+ NULL,
+ word_complete,
+ matches);
+ return matches.GetSize();
+ }
+
+};
+
+
+#pragma mark CommandObjectTargetSymbols
+
+//-------------------------------------------------------------------------
+// CommandObjectTargetSymbols
+//-------------------------------------------------------------------------
+
+class CommandObjectTargetSymbols : public CommandObjectMultiword
+{
+public:
+ //------------------------------------------------------------------
+ // Constructors and Destructors
+ //------------------------------------------------------------------
+ CommandObjectTargetSymbols(CommandInterpreter &interpreter) :
+ CommandObjectMultiword (interpreter,
+ "target symbols",
+ "A set of commands for adding and managing debug symbol files.",
+ "target symbols <sub-command> ...")
+ {
+ LoadSubCommand ("add", CommandObjectSP (new CommandObjectTargetSymbolsAdd (interpreter)));
+
+ }
+ virtual
+ ~CommandObjectTargetSymbols()
+ {
+ }
+
+private:
+ //------------------------------------------------------------------
+ // For CommandObjectTargetModules only
+ //------------------------------------------------------------------
+ DISALLOW_COPY_AND_ASSIGN (CommandObjectTargetSymbols);
+};
+
+
#pragma mark CommandObjectTargetStopHookAdd
//-------------------------------------------------------------------------
@@ -4187,6 +4383,7 @@
LoadSubCommand ("select", CommandObjectSP (new CommandObjectTargetSelect (interpreter)));
LoadSubCommand ("stop-hook", CommandObjectSP (new CommandObjectMultiwordTargetStopHooks (interpreter)));
LoadSubCommand ("modules", CommandObjectSP (new CommandObjectTargetModules (interpreter)));
+ LoadSubCommand ("symbols", CommandObjectSP (new CommandObjectTargetSymbols (interpreter)));
LoadSubCommand ("variable", CommandObjectSP (new CommandObjectTargetVariable (interpreter)));
}
Modified: lldb/trunk/source/Core/Address.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Core/Address.cpp (original)
+++ lldb/trunk/source/Core/Address.cpp Thu Feb 23 19:59:29 2012
@@ -55,11 +55,11 @@
if (byte_order == eByteOrderInvalid || addr_size == 0)
{
- Module *module = address.GetModulePtr();
- if (module)
+ ModuleSP module_sp (address.GetModule());
+ if (module_sp)
{
- byte_order = module->GetArchitecture().GetByteOrder();
- addr_size = module->GetArchitecture().GetAddressByteSize();
+ byte_order = module_sp->GetArchitecture().GetByteOrder();
+ addr_size = module_sp->GetArchitecture().GetAddressByteSize();
}
}
return byte_order != eByteOrderInvalid && addr_size != 0;
@@ -118,17 +118,17 @@
{
// If we were not running, yet able to read an integer, we must
// have a module
- Module *module = address.GetModulePtr();
- assert (module);
- if (module->ResolveFileAddress(deref_addr, deref_so_addr))
+ ModuleSP module_sp (address.GetModule());
+
+ assert (module_sp);
+ if (module_sp->ResolveFileAddress(deref_addr, deref_so_addr))
return true;
}
// We couldn't make "deref_addr" into a section offset value, but we were
// able to read the address, so we return a section offset address with
// no section and "deref_addr" as the offset (address).
- deref_so_addr.SetSection(NULL);
- deref_so_addr.SetOffset(deref_addr);
+ deref_so_addr.SetRawAddress(deref_addr);
return true;
}
return false;
@@ -210,11 +210,17 @@
return total_len;
}
-Address::Address (addr_t address, const SectionList * sections) :
- m_section (NULL),
+Address::Address (lldb::addr_t abs_addr) :
+ m_section_wp (),
+ m_offset (abs_addr)
+{
+}
+
+Address::Address (addr_t address, const SectionList *section_list) :
+ m_section_wp (),
m_offset (LLDB_INVALID_ADDRESS)
{
- ResolveAddressUsingFileSections(address, sections);
+ ResolveAddressUsingFileSections(address, section_list);
}
const Address&
@@ -222,58 +228,47 @@
{
if (this != &rhs)
{
- m_section = rhs.m_section;
+ m_section_wp = rhs.m_section_wp;
m_offset = rhs.m_offset;
}
return *this;
}
bool
-Address::ResolveAddressUsingFileSections (addr_t addr, const SectionList *sections)
+Address::ResolveAddressUsingFileSections (addr_t file_addr, const SectionList *section_list)
{
- if (sections)
- m_section = sections->FindSectionContainingFileAddress(addr).get();
- else
- m_section = NULL;
-
- if (m_section != NULL)
+ if (section_list)
{
- assert( m_section->ContainsFileAddress(addr) );
- m_offset = addr - m_section->GetFileAddress();
- return true; // Successfully transformed addr into a section offset address
+ SectionSP section_sp (section_list->FindSectionContainingFileAddress(file_addr));
+ m_section_wp = section_sp;
+ if (section_sp)
+ {
+ assert( section_sp->ContainsFileAddress(file_addr) );
+ m_offset = file_addr - section_sp->GetFileAddress();
+ return true; // Successfully transformed addr into a section offset address
+ }
}
-
- m_offset = addr;
+ m_offset = file_addr;
return false; // Failed to resolve this address to a section offset value
}
-Module *
-Address::GetModulePtr () const
-{
- if (m_section)
- return m_section->GetModule();
- return NULL;
-}
-
ModuleSP
-Address::GetModuleSP () const
+Address::GetModule () const
{
lldb::ModuleSP module_sp;
- if (m_section)
- {
- Module *module = m_section->GetModule();
- if (module)
- module_sp = module->shared_from_this();
- }
+ SectionSP section_sp (GetSection());
+ if (section_sp)
+ module_sp = section_sp->GetModule();
return module_sp;
}
addr_t
Address::GetFileAddress () const
{
- if (m_section != NULL)
+ SectionSP section_sp (GetSection());
+ if (section_sp)
{
- addr_t sect_file_addr = m_section->GetFileAddress();
+ addr_t sect_file_addr = section_sp->GetFileAddress();
if (sect_file_addr == LLDB_INVALID_ADDRESS)
{
// Section isn't resolved, we can't return a valid file address
@@ -290,7 +285,8 @@
addr_t
Address::GetLoadAddress (Target *target) const
{
- if (m_section == NULL)
+ SectionSP section_sp (GetSection());
+ if (!section_sp)
{
// No section, we just return the offset since it is the value in this case
return m_offset;
@@ -298,7 +294,7 @@
if (target)
{
- addr_t sect_load_addr = m_section->GetLoadBaseAddress (target);
+ addr_t sect_load_addr = section_sp->GetLoadBaseAddress (target);
if (sect_load_addr != LLDB_INVALID_ADDRESS)
{
@@ -359,7 +355,8 @@
Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, DumpStyle fallback_style, uint32_t addr_size) const
{
// If the section was NULL, only load address is going to work.
- if (m_section == NULL)
+ SectionSP section_sp (GetSection());
+ if (!section_sp)
style = DumpStyleLoadAddress;
ExecutionContext exe_ctx (exe_scope);
@@ -381,9 +378,9 @@
return false;
case DumpStyleSectionNameOffset:
- if (m_section != NULL)
+ if (section_sp)
{
- m_section->DumpName(s);
+ section_sp->DumpName(s);
s->Printf (" + %llu", m_offset);
}
else
@@ -393,13 +390,13 @@
break;
case DumpStyleSectionPointerOffset:
- s->Printf("(Section *)%p + ", m_section);
+ s->Printf("(Section *)%p + ", section_sp.get());
s->Address(m_offset, addr_size);
break;
case DumpStyleModuleWithFileAddress:
- if (m_section)
- s->Printf("%s[", m_section->GetModule()->GetFileSpec().GetFilename().AsCString());
+ if (section_sp)
+ s->Printf("%s[", section_sp->GetModule()->GetFileSpec().GetFilename().AsCString());
// Fall through
case DumpStyleFileAddress:
{
@@ -411,7 +408,7 @@
return false;
}
s->Address (file_addr, addr_size);
- if (style == DumpStyleModuleWithFileAddress && m_section)
+ if (style == DumpStyleModuleWithFileAddress && section_sp)
s->PutChar(']');
}
break;
@@ -442,23 +439,22 @@
}
uint32_t pointer_size = 4;
- Module *module = GetModulePtr();
+ ModuleSP module_sp (GetModule());
if (target)
pointer_size = target->GetArchitecture().GetAddressByteSize();
- else if (module)
- pointer_size = module->GetArchitecture().GetAddressByteSize();
+ else if (module_sp)
+ pointer_size = module_sp->GetArchitecture().GetAddressByteSize();
bool showed_info = false;
- const Section *section = GetSection();
- if (section)
+ if (section_sp)
{
- SectionType sect_type = section->GetType();
+ SectionType sect_type = section_sp->GetType();
switch (sect_type)
{
case eSectionTypeData:
- if (module)
+ if (module_sp)
{
- ObjectFile *objfile = module->GetObjectFile();
+ ObjectFile *objfile = module_sp->GetObjectFile();
if (objfile)
{
Symtab *symtab = objfile->GetSymtab();
@@ -623,10 +619,10 @@
if (!showed_info)
{
- if (module)
+ if (module_sp)
{
SymbolContext sc;
- module->ResolveSymbolContextForAddress(*this, eSymbolContextEverything, sc);
+ module_sp->ResolveSymbolContextForAddress(*this, eSymbolContextEverything, sc);
if (sc.function || sc.symbol)
{
bool show_stop_context = true;
@@ -678,11 +674,11 @@
case DumpStyleDetailedSymbolContext:
if (IsSectionOffset())
{
- Module *module = GetModulePtr();
- if (module)
+ ModuleSP module_sp (GetModule());
+ if (module_sp)
{
SymbolContext sc;
- module->ResolveSymbolContextForAddress(*this, eSymbolContextEverything, sc);
+ module_sp->ResolveSymbolContextForAddress(*this, eSymbolContextEverything, sc);
if (sc.symbol)
{
// If we have just a symbol make sure it is in the same section
@@ -741,12 +737,14 @@
{
sc->Clear();
// Absolute addresses don't have enough information to reconstruct even their target.
- if (m_section)
+
+ SectionSP section_sp (GetSection());
+ if (section_sp)
{
- Module *address_module = m_section->GetModule();
- if (address_module)
+ ModuleSP module_sp (section_sp->GetModule());
+ if (module_sp)
{
- sc->module_sp = address_module->shared_from_this();
+ sc->module_sp = module_sp;
if (sc->module_sp)
return sc->module_sp->ResolveSymbolContextForAddress (*this, resolve_scope, *sc);
}
@@ -754,21 +752,23 @@
return 0;
}
-Module *
+ModuleSP
Address::CalculateSymbolContextModule () const
{
- if (m_section)
- return m_section->GetModule();
- return NULL;
+ SectionSP section_sp (GetSection());
+ if (section_sp)
+ return section_sp->GetModule();
+ return ModuleSP();
}
CompileUnit *
Address::CalculateSymbolContextCompileUnit () const
{
- if (m_section)
+ SectionSP section_sp (GetSection());
+ if (section_sp)
{
SymbolContext sc;
- sc.module_sp = m_section->GetModule()->shared_from_this();
+ sc.module_sp = section_sp->GetModule();
if (sc.module_sp)
{
sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextCompUnit, sc);
@@ -781,10 +781,11 @@
Function *
Address::CalculateSymbolContextFunction () const
{
- if (m_section)
+ SectionSP section_sp (GetSection());
+ if (section_sp)
{
SymbolContext sc;
- sc.module_sp = m_section->GetModule()->shared_from_this();
+ sc.module_sp = section_sp->GetModule();
if (sc.module_sp)
{
sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextFunction, sc);
@@ -797,10 +798,11 @@
Block *
Address::CalculateSymbolContextBlock () const
{
- if (m_section)
+ SectionSP section_sp (GetSection());
+ if (section_sp)
{
SymbolContext sc;
- sc.module_sp = m_section->GetModule()->shared_from_this();
+ sc.module_sp = section_sp->GetModule();
if (sc.module_sp)
{
sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextBlock, sc);
@@ -813,10 +815,11 @@
Symbol *
Address::CalculateSymbolContextSymbol () const
{
- if (m_section)
+ SectionSP section_sp (GetSection());
+ if (section_sp)
{
SymbolContext sc;
- sc.module_sp = m_section->GetModule()->shared_from_this();
+ sc.module_sp = section_sp->GetModule();
if (sc.module_sp)
{
sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextSymbol, sc);
@@ -829,10 +832,11 @@
bool
Address::CalculateSymbolContextLineEntry (LineEntry &line_entry) const
{
- if (m_section)
+ SectionSP section_sp (GetSection());
+ if (section_sp)
{
SymbolContext sc;
- sc.module_sp = m_section->GetModule()->shared_from_this();
+ sc.module_sp = section_sp->GetModule();
if (sc.module_sp)
{
sc.module_sp->ResolveSymbolContextForAddress (*this, eSymbolContextLineEntry, sc);
@@ -876,8 +880,10 @@
int
Address::CompareModulePointerAndOffset (const Address& a, const Address& b)
{
- Module *a_module = a.GetModulePtr ();
- Module *b_module = b.GetModulePtr ();
+ ModuleSP a_module_sp (a.GetModule());
+ ModuleSP b_module_sp (b.GetModule());
+ Module *a_module = a_module_sp.get();
+ Module *b_module = b_module_sp.get();
if (a_module < b_module)
return -1;
if (a_module > b_module)
@@ -921,8 +927,10 @@
bool
lldb_private::operator< (const Address& lhs, const Address& rhs)
{
- Module *lhs_module = lhs.GetModulePtr();
- Module *rhs_module = rhs.GetModulePtr();
+ ModuleSP lhs_module_sp (lhs.GetModule());
+ ModuleSP rhs_module_sp (rhs.GetModule());
+ Module *lhs_module = lhs_module_sp.get();
+ Module *rhs_module = rhs_module_sp.get();
if (lhs_module == rhs_module)
{
// Addresses are in the same module, just compare the file addresses
@@ -939,8 +947,10 @@
bool
lldb_private::operator> (const Address& lhs, const Address& rhs)
{
- Module *lhs_module = lhs.GetModulePtr();
- Module *rhs_module = rhs.GetModulePtr();
+ ModuleSP lhs_module_sp (lhs.GetModule());
+ ModuleSP rhs_module_sp (rhs.GetModule());
+ Module *lhs_module = lhs_module_sp.get();
+ Module *rhs_module = rhs_module_sp.get();
if (lhs_module == rhs_module)
{
// Addresses are in the same module, just compare the file addresses
@@ -974,20 +984,22 @@
bool
Address::IsLinkedAddress () const
{
- return m_section && m_section->GetLinkedSection();
+ SectionSP section_sp (GetSection());
+ return section_sp && section_sp->GetLinkedSection();
}
void
Address::ResolveLinkedAddress ()
{
- if (m_section)
+ SectionSP section_sp (GetSection());
+ if (section_sp)
{
- const Section *linked_section = m_section->GetLinkedSection();
- if (linked_section)
+ SectionSP linked_section_sp (section_sp->GetLinkedSection());
+ if (linked_section_sp)
{
- m_offset += m_section->GetLinkedOffset();
- m_section = linked_section;
+ m_offset += section_sp->GetLinkedOffset();
+ m_section_wp = linked_section_sp;
}
}
}
@@ -995,10 +1007,10 @@
AddressClass
Address::GetAddressClass () const
{
- Module *module = GetModulePtr();
- if (module)
+ ModuleSP module_sp (GetModule());
+ if (module_sp)
{
- ObjectFile *obj_file = module->GetObjectFile();
+ ObjectFile *obj_file = module_sp->GetObjectFile();
if (obj_file)
return obj_file->GetAddressClass (GetFileAddress());
}
@@ -1010,7 +1022,7 @@
{
if (target && target->GetSectionLoadList().ResolveLoadAddress(load_addr, *this))
return true;
- m_section = NULL;
+ m_section_wp.reset();
m_offset = load_addr;
return false;
}
Modified: lldb/trunk/source/Core/AddressRange.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/AddressRange.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Core/AddressRange.cpp (original)
+++ lldb/trunk/source/Core/AddressRange.cpp Thu Feb 23 19:59:29 2012
@@ -28,7 +28,7 @@
{
}
-AddressRange::AddressRange (const Section* section, addr_t offset, addr_t byte_size) :
+AddressRange::AddressRange (const lldb::SectionSP §ion, addr_t offset, addr_t byte_size) :
m_base_addr(section, offset),
m_byte_size(byte_size)
{
@@ -177,9 +177,9 @@
{
if (show_module)
{
- Module *module = GetBaseAddress().GetModulePtr();
- if (module)
- s->Printf("%s", module->GetFileSpec().GetFilename().AsCString());
+ ModuleSP module_sp (GetBaseAddress().GetModule());
+ if (module_sp)
+ s->Printf("%s", module_sp->GetFileSpec().GetFilename().AsCString());
}
s->AddressRange(vmaddr, vmaddr + GetByteSize(), addr_size);
return true;
@@ -196,7 +196,7 @@
void
AddressRange::DumpDebug (Stream *s) const
{
- s->Printf("%p: AddressRange section = %p, offset = 0x%16.16llx, byte_size = 0x%16.16llx\n", this, m_base_addr.GetSection(), m_base_addr.GetOffset(), GetByteSize());
+ s->Printf("%p: AddressRange section = %p, offset = 0x%16.16llx, byte_size = 0x%16.16llx\n", this, m_base_addr.GetSection().get(), m_base_addr.GetOffset(), GetByteSize());
}
//
//bool
Modified: lldb/trunk/source/Core/DataExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/DataExtractor.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Core/DataExtractor.cpp (original)
+++ lldb/trunk/source/Core/DataExtractor.cpp Thu Feb 23 19:59:29 2012
@@ -1366,8 +1366,7 @@
lldb_private::Address so_addr;
if (!target_sp->GetSectionLoadList().ResolveLoadAddress(addr, so_addr))
{
- so_addr.SetOffset(addr);
- so_addr.SetSection(NULL);
+ so_addr.SetRawAddress(addr);
}
size_t bytes_consumed = disassembler_sp->DecodeInstructions (so_addr, *this, start_offset, item_count, false);
Modified: lldb/trunk/source/Core/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Core/Disassembler.cpp (original)
+++ lldb/trunk/source/Core/Disassembler.cpp Thu Feb 23 19:59:29 2012
@@ -386,10 +386,10 @@
prev_sc = sc;
- Module *module = addr.GetModulePtr();
- if (module)
+ ModuleSP module_sp (addr.GetModule());
+ if (module_sp)
{
- uint32_t resolved_mask = module->ResolveSymbolContextForAddress(addr, eSymbolContextEverything, sc);
+ uint32_t resolved_mask = module_sp->ResolveSymbolContextForAddress(addr, eSymbolContextEverything, sc);
if (resolved_mask)
{
if (num_mixed_context_lines)
Modified: lldb/trunk/source/Core/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Core/Module.cpp (original)
+++ lldb/trunk/source/Core/Module.cpp Thu Feb 23 19:59:29 2012
@@ -122,6 +122,7 @@
m_uuid (),
m_file (file_spec),
m_platform_file(),
+ m_symfile_spec (),
m_object_name (),
m_object_offset (),
m_objfile_sp (),
@@ -158,7 +159,7 @@
if (bytes_read == 512)
{
data_sp.reset (data_ap.release());
- m_objfile_sp = ObjectFile::FindPlugin(this, process_sp, header_addr, data_sp);
+ m_objfile_sp = ObjectFile::FindPlugin(shared_from_this(), process_sp, header_addr, data_sp);
if (m_objfile_sp)
{
// Once we get the object file, update our module with the object file's
@@ -170,13 +171,17 @@
}
}
-Module::Module(const FileSpec& file_spec, const ArchSpec& arch, const ConstString *object_name, off_t object_offset) :
+Module::Module(const FileSpec& file_spec,
+ const ArchSpec& arch,
+ const ConstString *object_name,
+ off_t object_offset) :
m_mutex (Mutex::eMutexTypeRecursive),
m_mod_time (file_spec.GetModificationTime()),
m_arch (arch),
m_uuid (),
m_file (file_spec),
m_platform_file(),
+ m_symfile_spec (),
m_object_name (),
m_object_offset (object_offset),
m_objfile_sp (),
@@ -320,10 +325,10 @@
sc->module_sp = shared_from_this();
}
-Module *
+ModuleSP
Module::CalculateSymbolContextModule ()
{
- return this;
+ return shared_from_this();
}
void
@@ -380,10 +385,10 @@
sc.Clear();
// Get the section from the section/offset address.
- const Section *section = so_addr.GetSection();
+ SectionSP section_sp (so_addr.GetSection());
// Make sure the section matches this module before we try and match anything
- if (section && section->GetModule() == this)
+ if (section_sp && section_sp->GetModule().get() == this)
{
// If the section offset based address resolved itself, then this
// is the right module.
@@ -667,7 +672,7 @@
if (obj_file != NULL)
{
Timer scoped_timer(__PRETTY_FUNCTION__, __PRETTY_FUNCTION__);
- m_symfile_ap.reset(SymbolVendor::FindPlugin(this));
+ m_symfile_ap.reset(SymbolVendor::FindPlugin(shared_from_this()));
m_did_load_symbol_vendor = true;
}
}
@@ -890,7 +895,11 @@
Timer scoped_timer(__PRETTY_FUNCTION__,
"Module::GetObjectFile () module = %s", GetFileSpec().GetFilename().AsCString(""));
DataBufferSP file_data_sp;
- m_objfile_sp = ObjectFile::FindPlugin(this, &m_file, m_object_offset, m_file.GetByteSize(), file_data_sp);
+ m_objfile_sp = ObjectFile::FindPlugin (shared_from_this(),
+ &m_file,
+ m_object_offset,
+ m_file.GetByteSize(),
+ file_data_sp);
if (m_objfile_sp)
{
// Once we get the object file, update our module with the object file's
Modified: lldb/trunk/source/Core/ModuleChild.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleChild.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Core/ModuleChild.cpp (original)
+++ lldb/trunk/source/Core/ModuleChild.cpp Thu Feb 23 19:59:29 2012
@@ -11,13 +11,13 @@
using namespace lldb_private;
-ModuleChild::ModuleChild (Module* module) :
- m_module(module)
+ModuleChild::ModuleChild (const lldb::ModuleSP &module_sp) :
+ m_module_wp (module_sp)
{
}
ModuleChild::ModuleChild (const ModuleChild& rhs) :
- m_module(rhs.m_module)
+ m_module_wp(rhs.m_module_wp)
{
}
@@ -29,24 +29,18 @@
ModuleChild::operator= (const ModuleChild& rhs)
{
if (this != &rhs)
- m_module = rhs.m_module;
+ m_module_wp = rhs.m_module_wp;
return *this;
}
-Module *
-ModuleChild::GetModule ()
-{
- return m_module;
-}
-
-Module *
+lldb::ModuleSP
ModuleChild::GetModule () const
{
- return m_module;
+ return m_module_wp.lock();
}
void
-ModuleChild::SetModule (Module *module)
+ModuleChild::SetModule (const lldb::ModuleSP &module_sp)
{
- m_module = module;
+ m_module_wp = module_sp;
}
Modified: lldb/trunk/source/Core/ModuleList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ModuleList.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Core/ModuleList.cpp (original)
+++ lldb/trunk/source/Core/ModuleList.cpp Thu Feb 23 19:59:29 2012
@@ -586,12 +586,12 @@
{
// The address is already section offset so it has a module
uint32_t resolved_flags = 0;
- Module *module = so_addr.GetModulePtr();
- if (module)
+ ModuleSP module_sp (so_addr.GetModule());
+ if (module_sp)
{
- resolved_flags = module->ResolveSymbolContextForAddress (so_addr,
- resolve_scope,
- sc);
+ resolved_flags = module_sp->ResolveSymbolContextForAddress (so_addr,
+ resolve_scope,
+ sc);
}
else
{
Modified: lldb/trunk/source/Core/Section.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Section.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Core/Section.cpp (original)
+++ lldb/trunk/source/Core/Section.cpp Thu Feb 23 19:59:29 2012
@@ -15,23 +15,19 @@
using namespace lldb;
using namespace lldb_private;
-Section::Section
-(
- Section *parent,
- Module* module,
- user_id_t sect_id,
- const ConstString &name,
- SectionType sect_type,
- addr_t file_addr,
- addr_t byte_size,
- uint64_t file_offset,
- uint64_t file_size,
- uint32_t flags
-) :
- ModuleChild (module),
+Section::Section (const ModuleSP &module_sp,
+ user_id_t sect_id,
+ const ConstString &name,
+ SectionType sect_type,
+ addr_t file_addr,
+ addr_t byte_size,
+ uint64_t file_offset,
+ uint64_t file_size,
+ uint32_t flags) :
+ ModuleChild (module_sp),
UserID (sect_id),
Flags (flags),
- m_parent (parent),
+ m_parent_wp (),
m_name (name),
m_type (sect_type),
m_file_addr (file_addr),
@@ -40,73 +36,92 @@
m_file_size (file_size),
m_children (),
m_fake (false),
- m_linked_section(NULL),
+ m_linked_section_wp(),
m_linked_offset (0)
{
+// printf ("Section::Section(%p): module=%p, sect_id = 0x%16.16llx, addr=[0x%16.16llx - 0x%16.16llx), file [0x%16.16llx - 0x%16.16llx), flags = 0x%8.8x, name = %s\n",
+// this, module_sp.get(), sect_id, file_addr, file_addr + byte_size, file_offset, file_offset + file_size, flags, name.GetCString());
}
-Section::~Section()
+Section::Section (const lldb::SectionSP &parent_section_sp,
+ const ModuleSP &module_sp,
+ user_id_t sect_id,
+ const ConstString &name,
+ SectionType sect_type,
+ addr_t file_addr,
+ addr_t byte_size,
+ uint64_t file_offset,
+ uint64_t file_size,
+ uint32_t flags) :
+ ModuleChild (module_sp),
+ UserID (sect_id),
+ Flags (flags),
+ m_parent_wp (),
+ m_name (name),
+ m_type (sect_type),
+ m_file_addr (file_addr),
+ m_byte_size (byte_size),
+ m_file_offset (file_offset),
+ m_file_size (file_size),
+ m_children (),
+ m_fake (false),
+ m_linked_section_wp(),
+ m_linked_offset (0)
{
+// printf ("Section::Section(%p): module=%p, sect_id = 0x%16.16llx, addr=[0x%16.16llx - 0x%16.16llx), file [0x%16.16llx - 0x%16.16llx), flags = 0x%8.8x, name = %s.%s\n",
+// this, module_sp.get(), sect_id, file_addr, file_addr + byte_size, file_offset, file_offset + file_size, flags, parent_section_sp->GetName().GetCString(), name.GetCString());
+ if (parent_section_sp)
+ m_parent_wp = parent_section_sp;
}
-
-// Get a valid shared pointer to this section object
-SectionSP
-Section::GetSharedPointer() const
-{
- SectionSP this_sp;
- if (m_parent)
- this_sp = m_parent->GetChildren().GetSharedPointer (this, false);
- else
- {
- ObjectFile *objfile = m_module->GetObjectFile();
- if (objfile)
- {
- SectionList *section_list = objfile->GetSectionList();
- if (section_list)
- this_sp = section_list->GetSharedPointer (this, false);
- }
- }
- return this_sp;
-}
-
-
-
-ConstString&
-Section::GetName()
+Section::~Section()
{
- if (m_linked_section)
- return const_cast<Section *>(m_linked_section)->GetName();
- return m_name;
+// printf ("Section::~Section(%p)\n", this);
}
const ConstString&
Section::GetName() const
{
- if (m_linked_section)
- return m_linked_section->GetName();
+ SectionSP linked_section_sp (m_linked_section_wp.lock());
+ if (linked_section_sp)
+ return linked_section_sp->GetName();
return m_name;
}
addr_t
Section::GetFileAddress () const
{
- if (m_parent)
+ SectionSP parent_sp (GetParent ());
+ if (parent_sp)
{
// This section has a parent which means m_file_addr is an offset into
// the parent section, so the file address for this section is the file
// address of the parent plus the offset
- return m_parent->GetFileAddress() + m_file_addr;
+ return parent_sp->GetFileAddress() + m_file_addr;
}
// This section has no parent, so m_file_addr is the file base address
return m_file_addr;
}
+lldb::addr_t
+Section::GetOffset () const
+{
+ // This section has a parent which means m_file_addr is an offset.
+ SectionSP parent_sp (GetParent ());
+ if (parent_sp)
+ return m_file_addr;
+
+ // This section has no parent, so there is no offset to be had
+ return 0;
+}
+
+
addr_t
Section::GetLinkedFileAddress () const
{
- if (m_linked_section)
- return m_linked_section->GetFileAddress() + m_linked_offset;
+ SectionSP linked_section_sp (m_linked_section_wp.lock());
+ if (linked_section_sp)
+ return linked_section_sp->GetFileAddress() + m_linked_offset;
return LLDB_INVALID_ADDRESS;
}
@@ -115,22 +130,26 @@
Section::GetLoadBaseAddress (Target *target) const
{
addr_t load_base_addr = LLDB_INVALID_ADDRESS;
- if (m_linked_section)
+ SectionSP linked_section_sp (m_linked_section_wp.lock());
+ if (linked_section_sp)
{
- load_base_addr = m_linked_section->GetLoadBaseAddress(target);
+ load_base_addr = linked_section_sp->GetLoadBaseAddress(target);
if (load_base_addr != LLDB_INVALID_ADDRESS)
load_base_addr += m_linked_offset;
}
else
- if (m_parent)
- {
- load_base_addr = m_parent->GetLoadBaseAddress (target);
- if (load_base_addr != LLDB_INVALID_ADDRESS)
- load_base_addr += GetOffset();
- }
- else
{
- load_base_addr = target->GetSectionLoadList().GetSectionLoadAddress (this);
+ SectionSP parent_sp (GetParent ());
+ if (parent_sp)
+ {
+ load_base_addr = parent_sp->GetLoadBaseAddress (target);
+ if (load_base_addr != LLDB_INVALID_ADDRESS)
+ load_base_addr += GetOffset();
+ }
+ else
+ {
+ load_base_addr = target->GetSectionLoadList().GetSectionLoadAddress (this);
+ }
}
return load_base_addr;
@@ -151,15 +170,16 @@
return child_section->ResolveContainedAddress (offset - child_offset, so_addr);
}
}
- if (m_linked_section)
+ SectionSP linked_section_sp (m_linked_section_wp.lock());
+ if (linked_section_sp)
{
so_addr.SetOffset(m_linked_offset + offset);
- so_addr.SetSection(m_linked_section);
+ so_addr.SetSection(linked_section_sp);
}
else
{
so_addr.SetOffset(offset);
- so_addr.SetSection(this);
+ so_addr.SetSection(const_cast<Section *>(this)->shared_from_this());
}
return true;
}
@@ -200,9 +220,9 @@
if (&a == &b)
return 0;
- const Module* a_module = a.GetModule();
- const Module* b_module = b.GetModule();
- if (a_module == b_module)
+ const ModuleSP a_module_sp = a.GetModule();
+ const ModuleSP b_module_sp = b.GetModule();
+ if (a_module_sp == b_module_sp)
{
user_id_t a_sect_uid = a.GetID();
user_id_t b_sect_uid = b.GetID();
@@ -215,7 +235,7 @@
else
{
// The modules are different, just compare the module pointers
- if (a_module < b_module)
+ if (a_module_sp.get() < b_module_sp.get())
return -1;
else
return 1; // We already know the modules aren't equal
@@ -232,11 +252,12 @@
bool resolved = true;
addr_t addr = LLDB_INVALID_ADDRESS;
+ SectionSP linked_section_sp (m_linked_section_wp.lock());
if (GetByteSize() == 0)
s->Printf("%39s", "");
else
{
- if (target && m_linked_section == NULL)
+ if (target && linked_section_sp.get() == NULL)
addr = GetLoadBaseAddress (target);
if (addr == LLDB_INVALID_ADDRESS)
@@ -256,13 +277,13 @@
s->EOL();
- if (m_linked_section)
+ if (linked_section_sp)
{
addr = LLDB_INVALID_ADDRESS;
resolved = true;
if (target)
{
- addr = m_linked_section->GetLoadBaseAddress(target);
+ addr = linked_section_sp->GetLoadBaseAddress(target);
if (addr != LLDB_INVALID_ADDRESS)
addr += m_linked_offset;
}
@@ -271,7 +292,7 @@
{
if (target)
resolved = false;
- addr = m_linked_section->GetFileAddress() + m_linked_offset;
+ addr = linked_section_sp->GetFileAddress() + m_linked_offset;
}
int indent = 26 + s->GetIndentLevel();
@@ -281,7 +302,7 @@
indent = 3 * (sizeof(uint32_t) * 2 + 2 + 1) + 1;
s->Printf("%c%*.*s", resolved ? ' ' : '*', indent, indent, "");
- m_linked_section->DumpName(s);
+ linked_section_sp->DumpName(s);
s->Printf(" + 0x%llx\n", m_linked_offset);
}
@@ -292,17 +313,22 @@
void
Section::DumpName (Stream *s) const
{
- if (m_parent == NULL)
+ SectionSP parent_sp (GetParent ());
+ if (parent_sp)
{
- // The top most section prints the module basename
- const char *module_basename = m_module->GetFileSpec().GetFilename().AsCString();
- if (module_basename && module_basename[0])
- s->Printf("%s.", module_basename);
+ parent_sp->DumpName (s);
+ s->PutChar('.');
}
else
{
- m_parent->DumpName (s);
- s->PutChar('.');
+ // The top most section prints the module basename
+ ModuleSP module_sp (GetModule());
+ if (module_sp)
+ {
+ const char *module_basename = module_sp->GetFileSpec().GetFilename().AsCString();
+ if (module_basename && module_basename[0])
+ s->Printf("%s.", module_basename);
+ }
}
m_name.Dump(s);
}
@@ -312,8 +338,9 @@
{
if (this == section)
return true;
- if (m_parent)
- return m_parent->IsDescendant (section);
+ SectionSP parent_sp (GetParent ());
+ if (parent_sp)
+ return parent_sp->IsDescendant (section);
return false;
}
@@ -336,11 +363,11 @@
}
void
-Section::SetLinkedLocation (const Section *linked_section, uint64_t linked_offset)
+Section::SetLinkedLocation (const lldb::SectionSP &linked_section_sp, uint64_t linked_offset)
{
- if (linked_section)
- m_module = linked_section->GetModule();
- m_linked_section = linked_section;
+ if (linked_section_sp)
+ m_module_wp = linked_section_sp->GetModule();
+ m_linked_section_wp = linked_section_sp;
m_linked_offset = linked_offset;
}
@@ -357,10 +384,11 @@
}
uint32_t
-SectionList::AddSection (SectionSP& sect_sp)
+SectionList::AddSection (const lldb::SectionSP& section_sp)
{
+ assert (section_sp.get());
uint32_t section_index = m_sections.size();
- m_sections.push_back(sect_sp);
+ m_sections.push_back(section_sp);
return section_index;
}
@@ -382,7 +410,7 @@
}
uint32_t
-SectionList::AddUniqueSection (SectionSP& sect_sp)
+SectionList::AddUniqueSection (const lldb::SectionSP& sect_sp)
{
uint32_t sect_idx = FindSectionIndex (sect_sp.get());
if (sect_idx == UINT32_MAX)
@@ -392,7 +420,7 @@
bool
-SectionList::ReplaceSection (user_id_t sect_id, SectionSP& sect_sp, uint32_t depth)
+SectionList::ReplaceSection (user_id_t sect_id, const lldb::SectionSP& sect_sp, uint32_t depth)
{
iterator sect_iter, end = m_sections.end();
for (sect_iter = m_sections.begin(); sect_iter != end; ++sect_iter)
@@ -441,19 +469,21 @@
{
SectionSP sect_sp;
// Check if we have a valid section string
- if (section_dstr)
+ if (section_dstr && !m_sections.empty())
{
const_iterator sect_iter;
const_iterator end = m_sections.end();
for (sect_iter = m_sections.begin(); sect_iter != end && sect_sp.get() == NULL; ++sect_iter)
{
- if ((*sect_iter)->GetName() == section_dstr)
+ Section *child_section = sect_iter->get();
+ assert (child_section);
+ if (child_section->GetName() == section_dstr)
{
sect_sp = *sect_iter;
}
else
{
- sect_sp = (*sect_iter)->GetChildren().FindSectionByName(section_dstr);
+ sect_sp = child_section->GetChildren().FindSectionByName(section_dstr);
}
}
}
@@ -508,32 +538,6 @@
}
SectionSP
-SectionList::GetSharedPointer (const Section *section, bool check_children) const
-{
- SectionSP sect_sp;
- if (section)
- {
- const_iterator sect_iter;
- const_iterator end = m_sections.end();
- for (sect_iter = m_sections.begin(); sect_iter != end && sect_sp.get() == NULL; ++sect_iter)
- {
- if (sect_iter->get() == section)
- {
- sect_sp = *sect_iter;
- break;
- }
- else if (check_children)
- {
- sect_sp = (*sect_iter)->GetChildren().GetSharedPointer (section, true);
- }
- }
- }
- return sect_sp;
-}
-
-
-
-SectionSP
SectionList::FindSectionContainingFileAddress (addr_t vm_addr, uint32_t depth) const
{
SectionSP sect_sp;
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Thu Feb 23 19:59:29 2012
@@ -817,11 +817,11 @@
{
case eAddressTypeFile:
{
- Module* module = GetModule();
- if (module)
+ ModuleSP module_sp (GetModule());
+ if (module_sp)
{
Address so_addr;
- module->ResolveFileAddress(addr, so_addr);
+ module_sp->ResolveFileAddress(addr, so_addr);
ExecutionContext exe_ctx (GetExecutionContextRef());
Target* target = exe_ctx.GetTargetPtr();
if (target)
@@ -873,7 +873,7 @@
{
UpdateValueIfNeeded(false);
ExecutionContext exe_ctx (GetExecutionContextRef());
- Error error = m_value.GetValueAsData(&exe_ctx, GetClangAST(), data, 0, GetModule());
+ Error error = m_value.GetValueAsData(&exe_ctx, GetClangAST(), data, 0, GetModule().get());
if (error.Fail())
return 0;
data.SetAddressByteSize(m_data.GetAddressByteSize());
@@ -956,7 +956,7 @@
}
if (cstr_address != 0 && cstr_address != LLDB_INVALID_ADDRESS)
{
- Address cstr_so_addr (NULL, cstr_address);
+ Address cstr_so_addr (cstr_address);
DataExtractor data;
size_t bytes_read = 0;
if (cstr_len > 0 && honor_array)
@@ -3383,7 +3383,7 @@
data.SetByteOrder (m_data.GetByteOrder());
data.SetAddressByteSize(m_data.GetAddressByteSize());
- m_error = m_value.GetValueAsData (&exe_ctx, ast, data, 0, GetModule());
+ m_error = m_value.GetValueAsData (&exe_ctx, ast, data, 0, GetModule().get());
valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
ast,
@@ -3543,7 +3543,7 @@
if (ptr_value != LLDB_INVALID_ADDRESS)
{
- Address ptr_addr (NULL, ptr_value);
+ Address ptr_addr (ptr_value);
ExecutionContext exe_ctx (GetExecutionContextRef());
valobj_sp = ValueObjectMemory::Create (exe_ctx.GetBestExecutionContextScope(),
name,
@@ -3562,7 +3562,7 @@
if (ptr_value != LLDB_INVALID_ADDRESS)
{
- Address ptr_addr (NULL, ptr_value);
+ Address ptr_addr (ptr_value);
ExecutionContext exe_ctx (GetExecutionContextRef());
valobj_sp = ValueObjectMemory::Create (exe_ctx.GetBestExecutionContextScope(),
name,
Modified: lldb/trunk/source/Core/ValueObjectChild.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectChild.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectChild.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectChild.cpp Thu Feb 23 19:59:29 2012
@@ -190,7 +190,7 @@
if (m_error.Success())
{
ExecutionContext exe_ctx (GetExecutionContextRef().Lock());
- m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST (), m_data, 0, GetModule());
+ m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST (), m_data, 0, GetModule().get());
}
}
else
Modified: lldb/trunk/source/Core/ValueObjectDynamicValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectDynamicValue.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectDynamicValue.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectDynamicValue.cpp Thu Feb 23 19:59:29 2012
@@ -118,7 +118,7 @@
SetValueDidChange (m_value.GetValueType() != old_value.GetValueType() || m_value.GetScalar() != old_value.GetScalar());
}
ExecutionContext exe_ctx (GetExecutionContextRef());
- m_error = m_value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule());
+ m_error = m_value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
SetValueDidChange (m_parent->GetValueDidChange());
return true;
}
@@ -287,7 +287,7 @@
if (m_type_sp)
SetValueDidChange(true);
m_value = m_parent->GetValue();
- m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule());
+ m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
return m_error.Success();
}
@@ -336,7 +336,7 @@
{
// The variable value is in the Scalar value inside the m_value.
// We can point our m_data right to it.
- m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule());
+ m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
if (m_error.Success())
{
if (ClangASTContext::IsAggregateType (GetClangType()))
Modified: lldb/trunk/source/Core/ValueObjectMemory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectMemory.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectMemory.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectMemory.cpp Thu Feb 23 19:59:29 2012
@@ -209,7 +209,7 @@
case Value::eValueTypeScalar:
// The variable value is in the Scalar value inside the m_value.
// We can point our m_data right to it.
- m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule());
+ m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
break;
case Value::eValueTypeFileAddress:
@@ -251,7 +251,7 @@
else
value.SetContext(Value::eContextTypeClangType, m_clang_type.GetOpaqueQualType());
- m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule());
+ m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
}
break;
}
@@ -272,10 +272,10 @@
}
-Module *
+lldb::ModuleSP
ValueObjectMemory::GetModule()
{
- return m_address.GetModulePtr();
+ return m_address.GetModule();
}
Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectVariable.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectVariable.cpp Thu Feb 23 19:59:29 2012
@@ -180,7 +180,7 @@
case Value::eValueTypeScalar:
// The variable value is in the Scalar value inside the m_value.
// We can point our m_data right to it.
- m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule());
+ m_error = m_value.GetValueAsData (&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
break;
case Value::eValueTypeFileAddress:
@@ -233,7 +233,7 @@
// so it can extract read its value into m_data appropriately
Value value(m_value);
value.SetContext(Value::eContextTypeVariable, variable);
- m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule());
+ m_error = value.GetValueAsData(&exe_ctx, GetClangAST(), m_data, 0, GetModule().get());
}
break;
}
@@ -272,7 +272,7 @@
}
-Module *
+lldb::ModuleSP
ValueObjectVariable::GetModule()
{
if (m_variable_sp)
@@ -280,12 +280,10 @@
SymbolContextScope *sc_scope = m_variable_sp->GetSymbolContextScope();
if (sc_scope)
{
- SymbolContext sc;
- sc_scope->CalculateSymbolContext (&sc);
- return sc.module_sp.get();
+ return sc_scope->CalculateSymbolContextModule();
}
}
- return NULL;
+ return lldb::ModuleSP();
}
SymbolContextScope *
Modified: lldb/trunk/source/Expression/ClangExpressionParser.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionParser.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionParser.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionParser.cpp Thu Feb 23 19:59:29 2012
@@ -768,7 +768,7 @@
DataExtractor::TypeUInt8);
}
- disassembler->DecodeInstructions (Address (NULL, func_remote_addr), extractor, 0, UINT32_MAX, false);
+ disassembler->DecodeInstructions (Address (func_remote_addr), extractor, 0, UINT32_MAX, false);
InstructionList &instruction_list = disassembler->GetInstructionList();
const uint32_t max_opcode_byte_size = instruction_list.GetMaxOpcocdeByteSize();
Modified: lldb/trunk/source/Expression/ClangFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangFunction.cpp (original)
+++ lldb/trunk/source/Expression/ClangFunction.cpp Thu Feb 23 19:59:29 2012
@@ -398,7 +398,7 @@
// Okay, now run the function:
- Address wrapper_address (NULL, func_addr);
+ Address wrapper_address (func_addr);
ThreadPlan *new_plan = new ThreadPlanCallFunction (*thread,
wrapper_address,
ClangASTType(),
Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Thu Feb 23 19:59:29 2012
@@ -575,7 +575,7 @@
const bool stop_others = true;
const bool try_all_threads = true;
- Address wrapper_address (NULL, m_jit_start_addr);
+ Address wrapper_address (m_jit_start_addr);
lldb::ThreadPlanSP call_plan_sp(new ThreadPlanCallUserExpression (exe_ctx.GetThreadRef(),
wrapper_address,
struct_address,
Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original)
+++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Thu Feb 23 19:59:29 2012
@@ -125,10 +125,10 @@
}
else
{
- Module *module = inst_addr.GetModulePtr();
- if (module)
+ ModuleSP module_sp (inst_addr.GetModule());
+ if (module_sp)
{
- if (module->ResolveFileAddress(operand_value, so_addr))
+ if (module_sp->ResolveFileAddress(operand_value, so_addr))
so_addr.Dump (&comment,
exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL,
Address::DumpStyleResolvedDescriptionNoModule,
Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp Thu Feb 23 19:59:29 2012
@@ -1356,12 +1356,12 @@
AddressRange *ar = sym_ctx.symbol->GetAddressRangePtr();
if (ar)
{
- module_sp = ar->GetBaseAddress().GetModuleSP();
+ module_sp = ar->GetBaseAddress().GetModule();
}
}
if (module_sp.get() == NULL && sym_ctx.function)
{
- module_sp = sym_ctx.function->GetAddressRange().GetBaseAddress().GetModuleSP();
+ module_sp = sym_ctx.function->GetAddressRange().GetBaseAddress().GetModule();
}
if (module_sp.get() == NULL)
return false;
@@ -1622,9 +1622,9 @@
SymbolContext sc;
target_symbols.GetContextAtIndex(i, sc);
- Module* module_to_add = sc.symbol->CalculateSymbolContextModule();
- if (module_to_add)
- modules_to_search.AppendIfNeeded(module_to_add->shared_from_this());
+ ModuleSP module_sp (sc.symbol->CalculateSymbolContextModule());
+ if (module_sp)
+ modules_to_search.AppendIfNeeded(module_sp);
}
// If the original stub symbol is a resolver, then we don't want to break on the symbol with the
Modified: lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp Thu Feb 23 19:59:29 2012
@@ -180,8 +180,7 @@
lldb::addr_t dynamic_addr = original_ptr + offset_to_top;
if (!target->GetSectionLoadList().ResolveLoadAddress (dynamic_addr, dynamic_address))
{
- dynamic_address.SetOffset(dynamic_addr);
- dynamic_address.SetSection(NULL);
+ dynamic_address.SetRawAddress(dynamic_addr);
}
return true;
}
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Thu Feb 23 19:59:29 2012
@@ -251,8 +251,7 @@
if (error.Fail())
return false;
- address.SetSection (NULL);
- address.SetOffset(object_ptr);
+ address.SetRawAddress(object_ptr);
// First check the cache...
SymbolContext sc;
@@ -283,14 +282,14 @@
// If the ISA pointer points to one of the sections in the binary, then see if we can
// get the class name from the symbols.
- const Section *section = isa_address.GetSection();
+ SectionSP section_sp (isa_address.GetSection());
- if (section)
+ if (section_sp)
{
// If this points to a section that we know about, then this is
// some static class or nothing. See if it is in the right section
// and if its name is the right form.
- ConstString section_name = section->GetName();
+ ConstString section_name = section_sp->GetName();
static ConstString g_objc_class_section_name ("__objc_data");
if (section_name == g_objc_class_section_name)
{
Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCSymbolVendor.cpp Thu Feb 23 19:59:29 2012
@@ -18,7 +18,7 @@
using namespace lldb_private;
AppleObjCSymbolVendor::AppleObjCSymbolVendor(Process *process) :
- SymbolVendor(NULL),
+ SymbolVendor(lldb::ModuleSP()),
m_process(process->shared_from_this()),
m_ast_ctx(process->GetTarget().GetArchitecture().GetTriple().getTriple().c_str())
{
Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp Thu Feb 23 19:59:29 2012
@@ -263,7 +263,7 @@
ObjectContainer *
ObjectContainerBSDArchive::CreateInstance
(
- Module* module,
+ const lldb::ModuleSP &module_sp,
DataBufferSP& data_sp,
const FileSpec *file,
addr_t offset,
@@ -275,13 +275,13 @@
{
Timer scoped_timer (__PRETTY_FUNCTION__,
"ObjectContainerBSDArchive::CreateInstance (module = %s/%s, file = %p, file_offset = 0x%z8.8x, file_size = 0x%z8.8x)",
- module->GetFileSpec().GetDirectory().AsCString(),
- module->GetFileSpec().GetFilename().AsCString(),
+ module_sp->GetFileSpec().GetDirectory().AsCString(),
+ module_sp->GetFileSpec().GetFilename().AsCString(),
file, offset, length);
- Archive::shared_ptr archive_sp (Archive::FindCachedArchive (*file, module->GetArchitecture(), module->GetModificationTime()));
+ Archive::shared_ptr archive_sp (Archive::FindCachedArchive (*file, module_sp->GetArchitecture(), module_sp->GetModificationTime()));
- std::auto_ptr<ObjectContainerBSDArchive> container_ap(new ObjectContainerBSDArchive (module, data_sp, file, offset, length));
+ std::auto_ptr<ObjectContainerBSDArchive> container_ap(new ObjectContainerBSDArchive (module_sp, data_sp, file, offset, length));
if (container_ap.get())
{
@@ -316,13 +316,13 @@
ObjectContainerBSDArchive::ObjectContainerBSDArchive
(
- Module* module,
+ const lldb::ModuleSP &module_sp,
DataBufferSP& dataSP,
const lldb_private::FileSpec *file,
lldb::addr_t offset,
lldb::addr_t size
) :
- ObjectContainer (module, file, offset, size, dataSP),
+ ObjectContainer (module_sp, file, offset, size, dataSP),
m_archive_sp ()
{
}
@@ -345,10 +345,14 @@
{
if (m_data.GetByteSize() > 0)
{
- m_archive_sp = Archive::ParseAndCacheArchiveForFile (m_file,
- m_module->GetArchitecture(),
- m_module->GetModificationTime(),
- m_data);
+ ModuleSP module_sp (GetModule());
+ if (module_sp)
+ {
+ m_archive_sp = Archive::ParseAndCacheArchiveForFile (m_file,
+ module_sp->GetArchitecture(),
+ module_sp->GetModificationTime(),
+ m_data);
+ }
}
}
return m_archive_sp.get() != NULL;
@@ -383,15 +387,19 @@
ObjectFileSP
ObjectContainerBSDArchive::GetObjectFile (const FileSpec *file)
{
- if (m_module->GetObjectName() && m_archive_sp)
+ ModuleSP module_sp (GetModule());
+ if (module_sp)
{
- Object *object = m_archive_sp->FindObject (m_module->GetObjectName());
- if (object)
- return ObjectFile::FindPlugin (m_module,
- file,
- object->ar_file_offset,
- object->ar_file_size,
- m_data.GetSharedDataBuffer());
+ if (module_sp->GetObjectName() && m_archive_sp)
+ {
+ Object *object = m_archive_sp->FindObject (module_sp->GetObjectName());
+ if (object)
+ return ObjectFile::FindPlugin (module_sp,
+ file,
+ object->ar_file_offset,
+ object->ar_file_size,
+ m_data.GetSharedDataBuffer());
+ }
}
return ObjectFileSP();
}
Modified: lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h (original)
+++ lldb/trunk/source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h Thu Feb 23 19:59:29 2012
@@ -39,7 +39,7 @@
GetPluginDescriptionStatic();
static lldb_private::ObjectContainer *
- CreateInstance (lldb_private::Module* module,
+ CreateInstance (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& dataSP,
const lldb_private::FileSpec *file,
lldb::addr_t offset,
@@ -51,7 +51,7 @@
//------------------------------------------------------------------
// Member Functions
//------------------------------------------------------------------
- ObjectContainerBSDArchive (lldb_private::Module* module,
+ ObjectContainerBSDArchive (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& dataSP,
const lldb_private::FileSpec *file,
lldb::addr_t offset,
Modified: lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.cpp Thu Feb 23 19:59:29 2012
@@ -50,7 +50,7 @@
ObjectContainer *
ObjectContainerUniversalMachO::CreateInstance
(
- Module* module,
+ const lldb::ModuleSP &module_sp,
DataBufferSP& data_sp,
const FileSpec *file,
addr_t offset,
@@ -61,7 +61,7 @@
data.SetData (data_sp, offset, length);
if (ObjectContainerUniversalMachO::MagicBytesMatch(data))
{
- std::auto_ptr<ObjectContainerUniversalMachO> container_ap(new ObjectContainerUniversalMachO (module, data_sp, file, offset, length));
+ std::auto_ptr<ObjectContainerUniversalMachO> container_ap(new ObjectContainerUniversalMachO (module_sp, data_sp, file, offset, length));
if (container_ap->ParseHeader())
{
return container_ap.release();
@@ -82,13 +82,13 @@
ObjectContainerUniversalMachO::ObjectContainerUniversalMachO
(
- Module* module,
+ const lldb::ModuleSP &module_sp,
DataBufferSP& dataSP,
const FileSpec *file,
addr_t offset,
addr_t length
) :
- ObjectContainer (module, file, offset, length, dataSP),
+ ObjectContainer (module_sp, file, offset, length, dataSP),
m_header(),
m_fat_archs()
{
@@ -190,27 +190,31 @@
ArchSpec arch;
// If the module hasn't specified an architecture yet, set it to the default
// architecture:
- if (!m_module->GetArchitecture().IsValid())
+ ModuleSP module_sp (GetModule());
+ if (module_sp)
{
- arch = Target::GetDefaultArchitecture ();
- if (!arch.IsValid())
- arch.SetTriple (LLDB_ARCH_DEFAULT, NULL);
- }
- else
- arch = m_module->GetArchitecture();
-
- ArchSpec curr_arch;
- for (arch_idx = 0; arch_idx < m_header.nfat_arch; ++arch_idx)
- {
- if (GetArchitectureAtIndex (arch_idx, curr_arch))
+ if (!module_sp->GetArchitecture().IsValid())
+ {
+ arch = Target::GetDefaultArchitecture ();
+ if (!arch.IsValid())
+ arch.SetTriple (LLDB_ARCH_DEFAULT, NULL);
+ }
+ else
+ arch = module_sp->GetArchitecture();
+
+ ArchSpec curr_arch;
+ for (arch_idx = 0; arch_idx < m_header.nfat_arch; ++arch_idx)
{
- if (arch == curr_arch)
+ if (GetArchitectureAtIndex (arch_idx, curr_arch))
{
- return ObjectFile::FindPlugin (m_module,
- file,
- m_offset + m_fat_archs[arch_idx].offset,
- m_fat_archs[arch_idx].size,
- m_data.GetSharedDataBuffer());
+ if (arch == curr_arch)
+ {
+ return ObjectFile::FindPlugin (module_sp,
+ file,
+ m_offset + m_fat_archs[arch_idx].offset,
+ m_fat_archs[arch_idx].size,
+ m_data.GetSharedDataBuffer());
+ }
}
}
}
Modified: lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h (original)
+++ lldb/trunk/source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h Thu Feb 23 19:59:29 2012
@@ -35,7 +35,7 @@
GetPluginDescriptionStatic();
static lldb_private::ObjectContainer *
- CreateInstance (lldb_private::Module* module,
+ CreateInstance (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& dataSP,
const lldb_private::FileSpec *file,
lldb::addr_t offset,
@@ -47,7 +47,7 @@
//------------------------------------------------------------------
// Member Functions
//------------------------------------------------------------------
- ObjectContainerUniversalMachO (lldb_private::Module* module,
+ ObjectContainerUniversalMachO (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& dataSP,
const lldb_private::FileSpec *file,
lldb::addr_t offset,
Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp Thu Feb 23 19:59:29 2012
@@ -171,10 +171,11 @@
}
ObjectFile *
-ObjectFileELF::CreateInstance(Module *module,
- DataBufferSP &data_sp,
- const FileSpec *file, addr_t offset,
- addr_t length)
+ObjectFileELF::CreateInstance (const lldb::ModuleSP &module_sp,
+ DataBufferSP &data_sp,
+ const FileSpec *file,
+ addr_t offset,
+ addr_t length)
{
if (data_sp && data_sp->GetByteSize() > (llvm::ELF::EI_NIDENT + offset))
{
@@ -184,8 +185,7 @@
unsigned address_size = ELFHeader::AddressSizeInBytes(magic);
if (address_size == 4 || address_size == 8)
{
- std::auto_ptr<ObjectFileELF> objfile_ap(
- new ObjectFileELF(module, data_sp, file, offset, length));
+ std::auto_ptr<ObjectFileELF> objfile_ap(new ObjectFileELF(module_sp, data_sp, file, offset, length));
ArchSpec spec;
if (objfile_ap->GetArchitecture(spec) &&
objfile_ap->SetModulesArchitecture(spec))
@@ -198,7 +198,10 @@
ObjectFile*
-ObjectFileELF::CreateMemoryInstance(Module* module, DataBufferSP& data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr)
+ObjectFileELF::CreateMemoryInstance (const lldb::ModuleSP &module_sp,
+ DataBufferSP& data_sp,
+ const lldb::ProcessSP &process_sp,
+ lldb::addr_t header_addr)
{
return NULL;
}
@@ -228,17 +231,19 @@
// ObjectFile protocol
//------------------------------------------------------------------
-ObjectFileELF::ObjectFileELF(Module* module, DataBufferSP& dataSP,
- const FileSpec* file, addr_t offset,
- addr_t length)
- : ObjectFile(module, file, offset, length, dataSP),
- m_header(),
- m_program_headers(),
- m_section_headers(),
- m_sections_ap(),
- m_symtab_ap(),
- m_filespec_ap(),
- m_shstr_data()
+ObjectFileELF::ObjectFileELF (const lldb::ModuleSP &module_sp,
+ DataBufferSP& dataSP,
+ const FileSpec* file,
+ addr_t offset,
+ addr_t length) :
+ ObjectFile(module_sp, file, offset, length, dataSP),
+ m_header(),
+ m_program_headers(),
+ m_section_headers(),
+ m_sections_ap(),
+ m_symtab_ap(),
+ m_filespec_ap(),
+ m_shstr_data()
{
if (file)
m_file = *file;
@@ -346,20 +351,20 @@
if (!dynsym_hdr)
return Address();
- Section *dynsym = section_list->FindSectionByID(dynsym_id).get();
- if (!dynsym)
- return Address();
-
- for (size_t i = 0; i < m_dynamic_symbols.size(); ++i)
+ SectionSP dynsym_section_sp (section_list->FindSectionByID(dynsym_id));
+ if (dynsym_section_sp)
{
- ELFDynamic &symbol = m_dynamic_symbols[i];
-
- if (symbol.d_tag == DT_DEBUG)
+ for (size_t i = 0; i < m_dynamic_symbols.size(); ++i)
{
- // Compute the offset as the number of previous entries plus the
- // size of d_tag.
- addr_t offset = i * dynsym_hdr->sh_entsize + GetAddressByteSize();
- return Address(dynsym, offset);
+ ELFDynamic &symbol = m_dynamic_symbols[i];
+
+ if (symbol.d_tag == DT_DEBUG)
+ {
+ // Compute the offset as the number of previous entries plus the
+ // size of d_tag.
+ addr_t offset = i * dynsym_hdr->sh_entsize + GetAddressByteSize();
+ return Address(dynsym_section_sp, offset);
+ }
}
}
@@ -648,7 +653,6 @@
SectionSP section(new Section(
- 0, // Parent section.
GetModule(), // Module to which this section belongs.
SectionIndex(I), // Section ID.
name, // Section name.
@@ -697,7 +701,7 @@
if (symbol.Parse(symtab_data, &offset) == false)
break;
- Section *symbol_section = NULL;
+ SectionSP symbol_section_sp;
SymbolType symbol_type = eSymbolTypeInvalid;
Elf64_Half symbol_idx = symbol.st_shndx;
@@ -710,7 +714,7 @@
symbol_type = eSymbolTypeUndefined;
break;
default:
- symbol_section = section_list->GetSectionAtIndex(symbol_idx).get();
+ symbol_section_sp = section_list->GetSectionAtIndex(symbol_idx);
break;
}
@@ -749,9 +753,9 @@
if (symbol_type == eSymbolTypeInvalid)
{
- if (symbol_section)
+ if (symbol_section_sp)
{
- const ConstString §_name = symbol_section->GetName();
+ const ConstString §_name = symbol_section_sp->GetName();
if (sect_name == text_section_name ||
sect_name == init_section_name ||
sect_name == fini_section_name ||
@@ -772,25 +776,25 @@
}
uint64_t symbol_value = symbol.st_value;
- if (symbol_section != NULL)
- symbol_value -= symbol_section->GetFileAddress();
+ if (symbol_section_sp)
+ symbol_value -= symbol_section_sp->GetFileAddress();
const char *symbol_name = strtab_data.PeekCStr(symbol.st_name);
bool is_global = symbol.getBinding() == STB_GLOBAL;
uint32_t flags = symbol.st_other << 8 | symbol.st_info;
Symbol dc_symbol(
- i + start_id, // ID is the original symbol table index.
- symbol_name, // Symbol name.
- false, // Is the symbol name mangled?
- symbol_type, // Type of this symbol
- is_global, // Is this globally visible?
- false, // Is this symbol debug info?
- false, // Is this symbol a trampoline?
- false, // Is this symbol artificial?
- symbol_section, // Section in which this symbol is defined or null.
- symbol_value, // Offset in section or symbol value.
- symbol.st_size, // Size in bytes of this symbol.
- flags); // Symbol flags.
+ i + start_id, // ID is the original symbol table index.
+ symbol_name, // Symbol name.
+ false, // Is the symbol name mangled?
+ symbol_type, // Type of this symbol
+ is_global, // Is this globally visible?
+ false, // Is this symbol debug info?
+ false, // Is this symbol a trampoline?
+ false, // Is this symbol artificial?
+ symbol_section_sp, // Section in which this symbol is defined or null.
+ symbol_value, // Offset in section or symbol value.
+ symbol.st_size, // Size in bytes of this symbol.
+ flags); // Symbol flags.
symtab->AddSymbol(dc_symbol);
}
@@ -929,7 +933,7 @@
const ELFSectionHeader *rel_hdr,
const ELFSectionHeader *plt_hdr,
const ELFSectionHeader *sym_hdr,
- Section *plt_section,
+ const lldb::SectionSP &plt_section_sp,
DataExtractor &rel_data,
DataExtractor &symtab_data,
DataExtractor &strtab_data)
@@ -982,7 +986,7 @@
false, // Is this symbol debug info?
true, // Is this symbol a trampoline?
true, // Is this symbol artificial?
- plt_section, // Section in which this symbol is defined or null.
+ plt_section_sp, // Section in which this symbol is defined or null.
plt_index, // Offset in section or symbol value.
plt_entsize, // Size in bytes of this symbol.
0); // Symbol flags.
@@ -1029,8 +1033,8 @@
if (!rel_section)
return 0;
- Section *plt_section = section_list->FindSectionByID(plt_id).get();
- if (!plt_section)
+ SectionSP plt_section_sp (section_list->FindSectionByID(plt_id));
+ if (!plt_section_sp)
return 0;
Section *symtab = section_list->FindSectionByID(symtab_id).get();
@@ -1057,10 +1061,17 @@
if (!rel_type)
return 0;
- return ParsePLTRelocations(symbol_table, start_id, rel_type,
- &m_header, rel_hdr, plt_hdr, sym_hdr,
- plt_section,
- rel_data, symtab_data, strtab_data);
+ return ParsePLTRelocations (symbol_table,
+ start_id,
+ rel_type,
+ &m_header,
+ rel_hdr,
+ plt_hdr,
+ sym_hdr,
+ plt_section_sp,
+ rel_data,
+ symtab_data,
+ strtab_data);
}
Symtab *
Modified: lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h (original)
+++ lldb/trunk/source/Plugins/ObjectFile/ELF/ObjectFileELF.h Thu Feb 23 19:59:29 2012
@@ -45,14 +45,14 @@
GetPluginDescriptionStatic();
static lldb_private::ObjectFile *
- CreateInstance(lldb_private::Module* module,
+ CreateInstance(const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& dataSP,
const lldb_private::FileSpec* file,
lldb::addr_t offset,
lldb::addr_t length);
static lldb_private::ObjectFile *
- CreateMemoryInstance (lldb_private::Module* module,
+ CreateMemoryInstance (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& data_sp,
const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr);
@@ -118,7 +118,7 @@
CalculateStrata();
private:
- ObjectFileELF(lldb_private::Module* module,
+ ObjectFileELF(const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& dataSP,
const lldb_private::FileSpec* file,
lldb::addr_t offset,
Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Thu Feb 23 19:59:29 2012
@@ -364,11 +364,11 @@
ObjectFile *
-ObjectFileMachO::CreateInstance (Module* module, DataBufferSP& data_sp, const FileSpec* file, addr_t offset, addr_t length)
+ObjectFileMachO::CreateInstance (const lldb::ModuleSP &module_sp, DataBufferSP& data_sp, const FileSpec* file, addr_t offset, addr_t length)
{
if (ObjectFileMachO::MagicBytesMatch(data_sp, offset, length))
{
- std::auto_ptr<ObjectFile> objfile_ap(new ObjectFileMachO (module, data_sp, file, offset, length));
+ std::auto_ptr<ObjectFile> objfile_ap(new ObjectFileMachO (module_sp, data_sp, file, offset, length));
if (objfile_ap.get() && objfile_ap->ParseHeader())
return objfile_ap.release();
}
@@ -376,14 +376,14 @@
}
ObjectFile *
-ObjectFileMachO::CreateMemoryInstance (Module* module,
+ObjectFileMachO::CreateMemoryInstance (const lldb::ModuleSP &module_sp,
DataBufferSP& data_sp,
const ProcessSP &process_sp,
lldb::addr_t header_addr)
{
if (ObjectFileMachO::MagicBytesMatch(data_sp, 0, data_sp->GetByteSize()))
{
- std::auto_ptr<ObjectFile> objfile_ap(new ObjectFileMachO (module, data_sp, process_sp, header_addr));
+ std::auto_ptr<ObjectFile> objfile_ap(new ObjectFileMachO (module_sp, data_sp, process_sp, header_addr));
if (objfile_ap.get() && objfile_ap->ParseHeader())
return objfile_ap.release();
}
@@ -462,8 +462,8 @@
}
-ObjectFileMachO::ObjectFileMachO(Module* module, DataBufferSP& data_sp, const FileSpec* file, addr_t offset, addr_t length) :
- ObjectFile(module, file, offset, length, data_sp),
+ObjectFileMachO::ObjectFileMachO(const lldb::ModuleSP &module_sp, DataBufferSP& data_sp, const FileSpec* file, addr_t offset, addr_t length) :
+ ObjectFile(module_sp, file, offset, length, data_sp),
m_mutex (Mutex::eMutexTypeRecursive),
m_sections_ap(),
m_symtab_ap(),
@@ -477,11 +477,11 @@
::memset (&m_dysymtab, 0, sizeof(m_dysymtab));
}
-ObjectFileMachO::ObjectFileMachO (lldb_private::Module* module,
+ObjectFileMachO::ObjectFileMachO (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& header_data_sp,
const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr) :
- ObjectFile(module, process_sp, header_addr, header_data_sp),
+ ObjectFile(module_sp, process_sp, header_addr, header_data_sp),
m_mutex (Mutex::eMutexTypeRecursive),
m_sections_ap(),
m_symtab_ap(),
@@ -609,10 +609,10 @@
const AddressRange *range_ptr = symbol->GetAddressRangePtr();
if (range_ptr)
{
- const Section *section = range_ptr->GetBaseAddress().GetSection();
- if (section)
+ SectionSP section_sp (range_ptr->GetBaseAddress().GetSection());
+ if (section_sp)
{
- const SectionType section_type = section->GetType();
+ const SectionType section_type = section_sp->GetType();
switch (section_type)
{
case eSectionTypeInvalid: return eAddressClassUnknown;
@@ -746,6 +746,7 @@
uint32_t i;
const bool is_core = GetType() == eTypeCoreFile;
//bool dump_sections = false;
+ ModuleSP module_sp (GetModule());
for (i=0; i<m_header.ncmds; ++i)
{
const uint32_t load_cmd_offset = offset;
@@ -775,8 +776,7 @@
SectionSP segment_sp;
if (segment_name || is_core)
{
- segment_sp.reset(new Section (NULL,
- GetModule(), // Module to which this section belongs
+ segment_sp.reset(new Section (module_sp, // Module to which this section belongs
++segID << 8, // Section ID is the 1 based segment index shifted right by 8 bits as not to collide with any of the 256 section IDs that are possible
segment_name, // Name of this section
eSectionTypeContainer, // This section is a container of other sections.
@@ -872,16 +872,16 @@
else
{
// Create a fake section for the section's named segment
- segment_sp.reset(new Section(segment_sp.get(), // Parent section
- GetModule(), // Module to which this section belongs
- ++segID << 8, // Section ID is the 1 based segment index shifted right by 8 bits as not to collide with any of the 256 section IDs that are possible
- segment_name, // Name of this section
- eSectionTypeContainer, // This section is a container of other sections.
- sect64.addr, // File VM address == addresses as they are found in the object file
- sect64.size, // VM size in bytes of this section
- sect64.offset, // Offset to the data for this section in the file
- sect64.offset ? sect64.size : 0, // Size in bytes of this section as found in the the file
- load_cmd.flags)); // Flags for this section
+ segment_sp.reset(new Section (segment_sp, // Parent section
+ module_sp, // Module to which this section belongs
+ ++segID << 8, // Section ID is the 1 based segment index shifted right by 8 bits as not to collide with any of the 256 section IDs that are possible
+ segment_name, // Name of this section
+ eSectionTypeContainer, // This section is a container of other sections.
+ sect64.addr, // File VM address == addresses as they are found in the object file
+ sect64.size, // VM size in bytes of this section
+ sect64.offset, // Offset to the data for this section in the file
+ sect64.offset ? sect64.size : 0, // Size in bytes of this section as found in the the file
+ load_cmd.flags)); // Flags for this section
segment_sp->SetIsFake(true);
m_sections_ap->AddSection(segment_sp);
segment_sp->SetIsEncrypted (segment_is_encrypted);
@@ -1000,16 +1000,16 @@
}
}
- SectionSP section_sp(new Section(segment_sp.get(),
- GetModule(),
- ++sectID,
- section_name,
- sect_type,
- sect64.addr - segment_sp->GetFileAddress(),
- sect64.size,
- sect64.offset,
- sect64.offset == 0 ? 0 : sect64.size,
- sect64.flags));
+ SectionSP section_sp(new Section (segment_sp,
+ module_sp,
+ ++sectID,
+ section_name,
+ sect_type,
+ sect64.addr - segment_sp->GetFileAddress(),
+ sect64.size,
+ sect64.offset,
+ sect64.offset == 0 ? 0 : sect64.size,
+ sect64.flags));
// Set the section to be encrypted to match the segment
section_sp->SetIsEncrypted (segment_is_encrypted);
@@ -1081,21 +1081,21 @@
}
- Section *
+ SectionSP
GetSection (uint8_t n_sect, addr_t file_addr)
{
if (n_sect == 0)
- return NULL;
+ return SectionSP();
if (n_sect < m_section_infos.size())
{
- if (m_section_infos[n_sect].section == NULL)
+ if (!m_section_infos[n_sect].section_sp)
{
- Section *section = m_section_list->FindSectionByID (n_sect).get();
- m_section_infos[n_sect].section = section;
- if (section != NULL)
+ SectionSP section_sp (m_section_list->FindSectionByID (n_sect));
+ m_section_infos[n_sect].section_sp = section_sp;
+ if (section_sp != NULL)
{
- m_section_infos[n_sect].vm_range.SetBaseAddress (section->GetFileAddress());
- m_section_infos[n_sect].vm_range.SetByteSize (section->GetByteSize());
+ m_section_infos[n_sect].vm_range.SetBaseAddress (section_sp->GetFileAddress());
+ m_section_infos[n_sect].vm_range.SetByteSize (section_sp->GetByteSize());
}
else
{
@@ -1105,7 +1105,7 @@
if (m_section_infos[n_sect].vm_range.Contains(file_addr))
{
// Symbol is in section.
- return m_section_infos[n_sect].section;
+ return m_section_infos[n_sect].section_sp;
}
else if (m_section_infos[n_sect].vm_range.GetByteSize () == 0 &&
m_section_infos[n_sect].vm_range.GetBaseAddress() == file_addr)
@@ -1113,10 +1113,10 @@
// Symbol is in section with zero size, but has the same start
// address as the section. This can happen with linker symbols
// (symbols that start with the letter 'l' or 'L'.
- return m_section_infos[n_sect].section;
+ return m_section_infos[n_sect].section_sp;
}
}
- return m_section_list->FindSectionContainingFileAddress(file_addr).get();
+ return m_section_list->FindSectionContainingFileAddress(file_addr);
}
protected:
@@ -1124,12 +1124,12 @@
{
SectionInfo () :
vm_range(),
- section (NULL)
+ section_sp ()
{
}
VMRange vm_range;
- Section *section;
+ SectionSP section_sp;
};
SectionList *m_section_list;
std::vector<SectionInfo> m_section_infos;
@@ -1307,22 +1307,26 @@
const char *symbol_name = strtab_data.PeekCStr(nlist.n_strx);
if (symbol_name == NULL)
{
+ ModuleSP module_sp (GetModule());
// No symbol should be NULL, even the symbols with no
// string values should have an offset zero which points
// to an empty C-string
- Host::SystemLog (Host::eSystemLogError,
- "error: symbol[%u] has invalid string table offset 0x%x in %s/%s, ignoring symbol\n",
- nlist_idx,
- nlist.n_strx,
- m_module->GetFileSpec().GetDirectory().GetCString(),
- m_module->GetFileSpec().GetFilename().GetCString());
+ if (module_sp)
+ {
+ Host::SystemLog (Host::eSystemLogError,
+ "error: symbol[%u] has invalid string table offset 0x%x in %s/%s, ignoring symbol\n",
+ nlist_idx,
+ nlist.n_strx,
+ module_sp->GetFileSpec().GetDirectory().GetCString(),
+ module_sp->GetFileSpec().GetFilename().GetCString());
+ }
continue;
}
const char *symbol_name_non_abi_mangled = NULL;
if (symbol_name[0] == '\0')
symbol_name = NULL;
- Section* symbol_section = NULL;
+ SectionSP symbol_section;
bool add_nlist = true;
bool is_debug = ((nlist.n_type & NlistMaskStab) != 0);
@@ -2239,14 +2243,18 @@
// We couldn't read the UnixThread load command - maybe it wasn't there. As a fallback look for the
// "start" symbol in the main executable.
- SymbolContextList contexts;
- SymbolContext context;
- if (!m_module->FindSymbolsWithNameAndType(ConstString ("start"), eSymbolTypeCode, contexts))
- return m_entry_point_address;
+ ModuleSP module_sp (GetModule());
- contexts.GetContextAtIndex(0, context);
-
- m_entry_point_address = context.symbol->GetValue();
+ if (module_sp)
+ {
+ SymbolContextList contexts;
+ SymbolContext context;
+ if (module_sp->FindSymbolsWithNameAndType(ConstString ("start"), eSymbolTypeCode, contexts))
+ {
+ if (contexts.GetContextAtIndex(0, context))
+ m_entry_point_address = context.symbol->GetValue();
+ }
+ }
}
return m_entry_point_address;
@@ -2263,7 +2271,7 @@
SectionSP text_segment_sp (section_list->FindSectionByName (GetSegmentNameTEXT()));
if (text_segment_sp)
{
- header_addr.SetSection (text_segment_sp.get());
+ header_addr.SetSection (text_segment_sp);
header_addr.SetOffset (0);
}
}
Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h Thu Feb 23 19:59:29 2012
@@ -42,14 +42,14 @@
GetPluginDescriptionStatic();
static lldb_private::ObjectFile *
- CreateInstance (lldb_private::Module* module,
+ CreateInstance (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& dataSP,
const lldb_private::FileSpec* file,
lldb::addr_t offset,
lldb::addr_t length);
static lldb_private::ObjectFile *
- CreateMemoryInstance (lldb_private::Module* module,
+ CreateMemoryInstance (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& data_sp,
const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr);
@@ -62,13 +62,13 @@
//------------------------------------------------------------------
// Member Functions
//------------------------------------------------------------------
- ObjectFileMachO (lldb_private::Module* module,
+ ObjectFileMachO (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& dataSP,
const lldb_private::FileSpec* file,
lldb::addr_t offset,
lldb::addr_t length);
- ObjectFileMachO (lldb_private::Module* module,
+ ObjectFileMachO (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& dataSP,
const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr);
Modified: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp Thu Feb 23 19:59:29 2012
@@ -145,11 +145,11 @@
ObjectFile *
-ObjectFilePECOFF::CreateInstance (Module* module, DataBufferSP& dataSP, const FileSpec* file, addr_t offset, addr_t length)
+ObjectFilePECOFF::CreateInstance (const lldb::ModuleSP &module_sp, DataBufferSP& dataSP, const FileSpec* file, addr_t offset, addr_t length)
{
if (ObjectFilePECOFF::MagicBytesMatch(dataSP))
{
- std::auto_ptr<ObjectFile> objfile_ap(new ObjectFilePECOFF (module, dataSP, file, offset, length));
+ std::auto_ptr<ObjectFile> objfile_ap(new ObjectFilePECOFF (module_sp, dataSP, file, offset, length));
if (objfile_ap.get() && objfile_ap->ParseHeader())
return objfile_ap.release();
}
@@ -157,7 +157,7 @@
}
ObjectFile *
-ObjectFilePECOFF::CreateMemoryInstance (lldb_private::Module* module,
+ObjectFilePECOFF::CreateMemoryInstance (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& data_sp,
const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr)
@@ -175,12 +175,12 @@
}
-ObjectFilePECOFF::ObjectFilePECOFF (Module* module,
+ObjectFilePECOFF::ObjectFilePECOFF (const lldb::ModuleSP &module_sp,
DataBufferSP& dataSP,
const FileSpec* file,
addr_t offset,
addr_t length) :
- ObjectFile (module, file, offset, length, dataSP),
+ ObjectFile (module_sp, file, offset, length, dataSP),
m_mutex (Mutex::eMutexTypeRecursive),
m_dos_header (),
m_coff_header (),
@@ -537,7 +537,7 @@
symbol.type = symtab_data.GetU16 (&offset);
symbol.storage = symtab_data.GetU8 (&offset);
symbol.naux = symtab_data.GetU8 (&offset);
- Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect-1).get(), symbol.value);
+ Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect-1), symbol.value);
symbols[i].GetMangled ().SetValue (symbol_name.c_str(), symbol_name[0]=='_' && symbol_name[1] == 'Z');
symbols[i].SetValue(symbol_addr);
@@ -559,7 +559,7 @@
{
m_sections_ap.reset(new SectionList());
const uint32_t nsects = m_sect_headers.size();
- Module *module = GetModule();
+ ModuleSP module_sp (GetModule());
for (uint32_t idx = 0; idx<nsects; ++idx)
{
std::string sect_name;
@@ -624,8 +624,7 @@
// Use a segment ID of the segment index shifted left by 8 so they
// never conflict with any of the sections.
- SectionSP section_sp (new Section (NULL,
- module, // Module to which this section belongs
+ SectionSP section_sp (new Section (module_sp, // Module to which this section belongs
idx + 1, // Section ID is the 1 based segment index shifted right by 8 bits as not to collide with any of the 256 section IDs that are possible
const_sect_name, // Name of this section
section_type, // This section is a container of other sections.
Modified: lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h (original)
+++ lldb/trunk/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h Thu Feb 23 19:59:29 2012
@@ -36,14 +36,14 @@
GetPluginDescriptionStatic();
static ObjectFile *
- CreateInstance (lldb_private::Module* module,
+ CreateInstance (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& dataSP,
const lldb_private::FileSpec* file,
lldb::addr_t offset,
lldb::addr_t length);
static lldb_private::ObjectFile *
- CreateMemoryInstance (lldb_private::Module* module,
+ CreateMemoryInstance (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& data_sp,
const lldb::ProcessSP &process_sp,
lldb::addr_t header_addr);
@@ -51,7 +51,7 @@
MagicBytesMatch (lldb::DataBufferSP& dataSP);
- ObjectFilePECOFF (lldb_private::Module* module,
+ ObjectFilePECOFF (const lldb::ModuleSP &module_sp,
lldb::DataBufferSP& dataSP,
const lldb_private::FileSpec* file,
lldb::addr_t offset,
Modified: lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/RegisterContextLLDB.cpp Thu Feb 23 19:59:29 2012
@@ -128,7 +128,7 @@
{
m_current_offset = frame_sp->GetFrameCodeAddress().GetOffset() - m_start_pc.GetOffset();
}
- else if (frame_sp->GetFrameCodeAddress().GetModulePtr() == m_start_pc.GetModulePtr())
+ else if (frame_sp->GetFrameCodeAddress().GetModule() == m_start_pc.GetModule())
{
// This means that whatever symbol we kicked up isn't really correct
// as no should cross section boundaries... We really should NULL out
@@ -288,7 +288,8 @@
// If we don't have a Module for some reason, we're not going to find symbol/function information - just
// stick in some reasonable defaults and hope we can unwind past this frame.
- if (!m_current_pc.IsValid() || m_current_pc.GetModulePtr() == NULL)
+ ModuleSP pc_module_sp (m_current_pc.GetModule());
+ if (!m_current_pc.IsValid() || !pc_module_sp)
{
if (log)
{
@@ -401,7 +402,7 @@
}
// We require that eSymbolContextSymbol be successfully filled in or this context is of no use to us.
- if ((m_current_pc.GetModulePtr()->ResolveSymbolContextForAddress (m_current_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
+ if ((pc_module_sp->ResolveSymbolContextForAddress (m_current_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
{
m_sym_ctx_valid = true;
}
@@ -440,7 +441,7 @@
temporary_pc.SetOffset(m_current_pc.GetOffset() - 1);
m_sym_ctx.Clear();
m_sym_ctx_valid = false;
- if ((m_current_pc.GetModulePtr()->ResolveSymbolContextForAddress (temporary_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
+ if ((pc_module_sp->ResolveSymbolContextForAddress (temporary_pc, eSymbolContextFunction| eSymbolContextSymbol, m_sym_ctx) & eSymbolContextSymbol) == eSymbolContextSymbol)
{
m_sym_ctx_valid = true;
}
@@ -623,13 +624,15 @@
RegisterContextLLDB::GetFastUnwindPlanForFrame ()
{
UnwindPlanSP unwind_plan_sp;
- if (!m_current_pc.IsValid() || m_current_pc.GetModulePtr() == NULL || m_current_pc.GetModulePtr()->GetObjectFile() == NULL)
+ ModuleSP pc_module_sp (m_current_pc.GetModule());
+
+ if (!m_current_pc.IsValid() || !pc_module_sp || pc_module_sp->GetObjectFile() == NULL)
return unwind_plan_sp;
if (IsFrameZero ())
return unwind_plan_sp;
- FuncUnwindersSP func_unwinders_sp (m_current_pc.GetModulePtr()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx));
+ FuncUnwindersSP func_unwinders_sp (pc_module_sp->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx));
if (!func_unwinders_sp)
return unwind_plan_sp;
@@ -717,7 +720,8 @@
}
// No Module for the current pc, try using the architecture default unwind.
- if (!m_current_pc.IsValid() || m_current_pc.GetModulePtr() == NULL || m_current_pc.GetModulePtr()->GetObjectFile() == NULL)
+ ModuleSP pc_module_sp (m_current_pc.GetModule());
+ if (!m_current_pc.IsValid() || !pc_module_sp || pc_module_sp->GetObjectFile() == NULL)
{
m_frame_type = eNormalFrame;
return arch_default_unwind_plan_sp;
@@ -726,7 +730,7 @@
FuncUnwindersSP func_unwinders_sp;
if (m_sym_ctx_valid)
{
- func_unwinders_sp = m_current_pc.GetModulePtr()->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx);
+ func_unwinders_sp = pc_module_sp->GetObjectFile()->GetUnwindTable().GetFuncUnwindersContainingAddress (m_current_pc, m_sym_ctx);
}
// No FuncUnwinders available for this pc, try using architectural default unwind.
Modified: lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Utility/UnwindLLDB.cpp Thu Feb 23 19:59:29 2012
@@ -232,7 +232,7 @@
if (idx < num_frames)
{
Cursor *frame_cursor = m_frames[idx].get();
- reg_ctx_sp = frame_cursor->reg_ctx_lldb_sp->shared_from_this();
+ reg_ctx_sp = frame_cursor->reg_ctx_lldb_sp;
}
return reg_ctx_sp;
}
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Thu Feb 23 19:59:29 2012
@@ -303,7 +303,11 @@
SymbolFileDWARF::~SymbolFileDWARF()
{
if (m_is_external_ast_source)
- m_obj_file->GetModule()->GetClangASTContext().RemoveExternalSource ();
+ {
+ ModuleSP module_sp (m_obj_file->GetModule());
+ if (module_sp)
+ module_sp->GetClangASTContext().RemoveExternalSource ();
+ }
}
static const ConstString &
@@ -346,8 +350,8 @@
SymbolFileDWARF::InitializeObject()
{
// Install our external AST source callbacks so we can complete Clang types.
- Module *module = m_obj_file->GetModule();
- if (module)
+ ModuleSP module_sp (m_obj_file->GetModule());
+ if (module_sp)
{
const SectionList *section_list = m_obj_file->GetSectionList();
@@ -531,17 +535,17 @@
const SectionList *section_list = m_obj_file->GetSectionList();
if (section_list)
{
- Section *section = section_list->FindSectionByType(sect_type, true).get();
- if (section)
+ SectionSP section_sp (section_list->FindSectionByType(sect_type, true));
+ if (section_sp)
{
// See if we memory mapped the DWARF segment?
if (m_dwarf_data.GetByteSize())
{
- data.SetData(m_dwarf_data, section->GetOffset (), section->GetByteSize());
+ data.SetData(m_dwarf_data, section_sp->GetOffset (), section_sp->GetByteSize());
}
else
{
- if (m_obj_file->ReadSectionData (section, data) == 0)
+ if (m_obj_file->ReadSectionData (section_sp.get(), data) == 0)
data.Clear();
}
}
@@ -2183,7 +2187,7 @@
if (sc.function)
{
- sc.module_sp = sc.function->CalculateSymbolContextModule()->shared_from_this();
+ sc.module_sp = sc.function->CalculateSymbolContextModule();
return true;
}
@@ -2195,7 +2199,7 @@
{
Timer scoped_timer(__PRETTY_FUNCTION__,
"SymbolFileDWARF::ResolveSymbolContext (so_addr = { section = %p, offset = 0x%llx }, resolve_scope = 0x%8.8x)",
- so_addr.GetSection(),
+ so_addr.GetSection().get(),
so_addr.GetOffset(),
resolve_scope);
uint32_t resolved = 0;
@@ -2601,7 +2605,7 @@
if (num_matches)
{
SymbolContext sc;
- sc.module_sp = m_obj_file->GetModule()->shared_from_this();
+ sc.module_sp = m_obj_file->GetModule();
assert (sc.module_sp);
DWARFDebugInfo* debug_info = DebugInfo();
@@ -2687,7 +2691,7 @@
}
SymbolContext sc;
- sc.module_sp = m_obj_file->GetModule()->shared_from_this();
+ sc.module_sp = m_obj_file->GetModule();
assert (sc.module_sp);
DWARFCompileUnit* dwarf_cu = NULL;
Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Thu Feb 23 19:59:29 2012
@@ -281,7 +281,7 @@
comp_unit_info->debug_map_sections_sp.reset(new SectionList);
Symtab *exe_symtab = m_obj_file->GetSymtab();
- Module *oso_module = oso_objfile->GetModule();
+ ModuleSP oso_module_sp (oso_objfile->GetModule());
Symtab *oso_symtab = oso_objfile->GetSymtab();
//#define DEBUG_OSO_DMAP // Do not check in with this defined...
#if defined(DEBUG_OSO_DMAP)
@@ -330,8 +330,8 @@
if (oso_fun_symbol)
{
// If we found the symbol, then we
- Section* exe_fun_section = const_cast<Section *>(exe_symbol->GetAddressRangePtr()->GetBaseAddress().GetSection());
- Section* oso_fun_section = const_cast<Section *>(oso_fun_symbol->GetAddressRangePtr()->GetBaseAddress().GetSection());
+ SectionSP exe_fun_section (exe_symbol->GetAddressRangePtr()->GetBaseAddress().GetSection());
+ SectionSP oso_fun_section (oso_fun_symbol->GetAddressRangePtr()->GetBaseAddress().GetSection());
if (oso_fun_section)
{
// Now we create a section that we will add as a child of the
@@ -342,14 +342,14 @@
// size will reflect any size changes (ppc has been known to
// shrink function sizes when it gets rid of jump islands that
// aren't needed anymore).
- SectionSP oso_fun_section_sp (new Section (const_cast<Section *>(oso_fun_symbol->GetAddressRangePtr()->GetBaseAddress().GetSection()),
- oso_module, // Module (the .o file)
- sect_id++, // Section ID starts at 0x10000 and increments so the section IDs don't overlap with the standard mach IDs
- exe_symbol->GetMangled().GetName(Mangled::ePreferMangled), // Name the section the same as the symbol for which is was generated!
- eSectionTypeDebug,
- oso_fun_symbol->GetAddressRangePtr()->GetBaseAddress().GetOffset(), // File VM address offset in the current section
- exe_symbol->GetByteSize(), // File size (we need the size from the executable)
- 0, 0, 0));
+ SectionSP oso_fun_section_sp (new Section (oso_fun_symbol->GetAddressRangePtr()->GetBaseAddress().GetSection(),
+ oso_module_sp, // Module (the .o file)
+ sect_id++, // Section ID starts at 0x10000 and increments so the section IDs don't overlap with the standard mach IDs
+ exe_symbol->GetMangled().GetName(Mangled::ePreferMangled), // Name the section the same as the symbol for which is was generated!
+ eSectionTypeDebug,
+ oso_fun_symbol->GetAddressRangePtr()->GetBaseAddress().GetOffset(), // File VM address offset in the current section
+ exe_symbol->GetByteSize(), // File size (we need the size from the executable)
+ 0, 0, 0));
oso_fun_section_sp->SetLinkedLocation (exe_fun_section,
exe_symbol->GetValue().GetFileAddress() - exe_fun_section->GetFileAddress());
@@ -384,12 +384,12 @@
if (exe_symbol && oso_gsym_symbol && exe_symbol->GetAddressRangePtr() && oso_gsym_symbol->GetAddressRangePtr())
{
// If we found the symbol, then we
- Section* exe_gsym_section = const_cast<Section *>(exe_symbol->GetAddressRangePtr()->GetBaseAddress().GetSection());
- Section* oso_gsym_section = const_cast<Section *>(oso_gsym_symbol->GetAddressRangePtr()->GetBaseAddress().GetSection());
+ SectionSP exe_gsym_section (exe_symbol->GetAddressRangePtr()->GetBaseAddress().GetSection());
+ SectionSP oso_gsym_section (oso_gsym_symbol->GetAddressRangePtr()->GetBaseAddress().GetSection());
if (oso_gsym_section)
{
- SectionSP oso_gsym_section_sp (new Section (const_cast<Section *>(oso_gsym_symbol->GetAddressRangePtr()->GetBaseAddress().GetSection()),
- oso_module, // Module (the .o file)
+ SectionSP oso_gsym_section_sp (new Section (oso_gsym_symbol->GetAddressRangePtr()->GetBaseAddress().GetSection(),
+ oso_module_sp, // Module (the .o file)
sect_id++, // Section ID starts at 0x10000 and increments so the section IDs don't overlap with the standard mach IDs
exe_symbol->GetMangled().GetName(Mangled::ePreferMangled), // Name the section the same as the symbol for which is was generated!
eSectionTypeDebug,
@@ -624,7 +624,7 @@
if (oso_symbol_section_sp)
{
const addr_t linked_file_addr = oso_symbol_section_sp->GetLinkedFileAddress();
- Address oso_so_addr (oso_symbol_section_sp.get(), exe_file_addr - linked_file_addr);
+ Address oso_so_addr (oso_symbol_section_sp, exe_file_addr - linked_file_addr);
if (oso_so_addr.IsSectionOffset())
resolved_flags |= oso_dwarf->ResolveSymbolContext (oso_so_addr, resolve_scope, sc);
}
@@ -855,7 +855,7 @@
static void
-RemoveFunctionsWithModuleNotEqualTo (Module *module, SymbolContextList &sc_list, uint32_t start_idx)
+RemoveFunctionsWithModuleNotEqualTo (const ModuleSP &module_sp, SymbolContextList &sc_list, uint32_t start_idx)
{
// We found functions in .o files. Not all functions in the .o files
// will have made it into the final output file. The ones that did
@@ -870,8 +870,8 @@
sc_list.GetContextAtIndex(i, sc);
if (sc.function)
{
- const Section *section = sc.function->GetAddressRange().GetBaseAddress().GetSection();
- if (section->GetModule() != module)
+ const SectionSP section_sp (sc.function->GetAddressRange().GetBaseAddress().GetSection());
+ if (section_sp->GetModule() != module_sp)
{
sc_list.RemoveContextAtIndex(i);
continue;
Modified: lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp Thu Feb 23 19:59:29 2012
@@ -161,7 +161,7 @@
{
const Symbol *cu_symbol = m_obj_file->GetSymtab()->SymbolAtIndex(m_source_indexes[idx]);
if (cu_symbol)
- cu_sp.reset(new CompileUnit(m_obj_file->GetModule(), NULL, cu_symbol->GetMangled().GetName().AsCString(), 0, eLanguageTypeUnknown));
+ cu_sp.reset(new CompileUnit (m_obj_file->GetModule(), NULL, cu_symbol->GetMangled().GetName().AsCString(), 0, eLanguageTypeUnknown));
}
return cu_sp;
}
Modified: lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp Thu Feb 23 19:59:29 2012
@@ -24,8 +24,8 @@
//----------------------------------------------------------------------
// SymbolVendorMacOSX constructor
//----------------------------------------------------------------------
-SymbolVendorMacOSX::SymbolVendorMacOSX(Module *module) :
- SymbolVendor(module)
+SymbolVendorMacOSX::SymbolVendorMacOSX(const lldb::ModuleSP &module_sp) :
+ SymbolVendor (module_sp)
{
}
@@ -118,44 +118,50 @@
// also allow for finding separate debug information files.
//----------------------------------------------------------------------
SymbolVendor*
-SymbolVendorMacOSX::CreateInstance(Module* module)
+SymbolVendorMacOSX::CreateInstance (const lldb::ModuleSP &module_sp)
{
Timer scoped_timer (__PRETTY_FUNCTION__,
"SymbolVendorMacOSX::CreateInstance (module = %s/%s)",
- module->GetFileSpec().GetDirectory().AsCString(),
- module->GetFileSpec().GetFilename().AsCString());
- SymbolVendorMacOSX* symbol_vendor = new SymbolVendorMacOSX(module);
+ module_sp->GetFileSpec().GetDirectory().AsCString(),
+ module_sp->GetFileSpec().GetFilename().AsCString());
+ SymbolVendorMacOSX* symbol_vendor = new SymbolVendorMacOSX(module_sp);
if (symbol_vendor)
{
char path[PATH_MAX];
path[0] = '\0';
// Try and locate the dSYM file on Mac OS X
- ObjectFile * obj_file = module->GetObjectFile();
+ ObjectFile * obj_file = module_sp->GetObjectFile();
if (obj_file)
{
Timer scoped_timer2 ("SymbolVendorMacOSX::CreateInstance () locate dSYM",
"SymbolVendorMacOSX::CreateInstance (module = %s/%s) locate dSYM",
- module->GetFileSpec().GetDirectory().AsCString(),
- module->GetFileSpec().GetFilename().AsCString());
+ module_sp->GetFileSpec().GetDirectory().AsCString(),
+ module_sp->GetFileSpec().GetFilename().AsCString());
- FileSpec dsym_fspec;
+ // First check to see if the module has a symbol file in mind already.
+ // If it does, then we MUST use that.
+ FileSpec dsym_fspec (module_sp->GetSymbolFileFileSpec());
+
ObjectFileSP dsym_objfile_sp;
- const FileSpec &file_spec = obj_file->GetFileSpec();
- if (file_spec)
+ if (!dsym_fspec)
{
- dsym_fspec = Symbols::LocateExecutableSymbolFile (&file_spec, &module->GetArchitecture(), &module->GetUUID());
-
- if (dsym_fspec)
+ // No symbol file was specified in the module, lets try and find
+ // one ourselves.
+ const FileSpec &file_spec = obj_file->GetFileSpec();
+ if (file_spec)
+ dsym_fspec = Symbols::LocateExecutableSymbolFile (&file_spec, &module_sp->GetArchitecture(), &module_sp->GetUUID());
+ }
+
+ if (dsym_fspec)
+ {
+ DataBufferSP dsym_file_data_sp;
+ dsym_objfile_sp = ObjectFile::FindPlugin(module_sp, &dsym_fspec, 0, dsym_fspec.GetByteSize(), dsym_file_data_sp);
+ if (UUIDsMatch(module_sp.get(), dsym_objfile_sp.get()))
{
- DataBufferSP dsym_file_data_sp;
- dsym_objfile_sp = ObjectFile::FindPlugin(module, &dsym_fspec, 0, dsym_fspec.GetByteSize(), dsym_file_data_sp);
- if (UUIDsMatch(module, dsym_objfile_sp.get()))
- {
- ReplaceDSYMSectionsWithExecutableSections (obj_file, dsym_objfile_sp.get());
- symbol_vendor->AddSymbolFileRepresentation(dsym_objfile_sp);
- return symbol_vendor;
- }
+ ReplaceDSYMSectionsWithExecutableSections (obj_file, dsym_objfile_sp.get());
+ symbol_vendor->AddSymbolFileRepresentation(dsym_objfile_sp);
+ return symbol_vendor;
}
}
Modified: lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h (original)
+++ lldb/trunk/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h Thu Feb 23 19:59:29 2012
@@ -32,12 +32,12 @@
GetPluginDescriptionStatic();
static lldb_private::SymbolVendor*
- CreateInstance (lldb_private::Module *module);
+ CreateInstance (const lldb::ModuleSP &module_sp);
//------------------------------------------------------------------
// Constructors and Destructors
//------------------------------------------------------------------
- SymbolVendorMacOSX (lldb_private::Module *module);
+ SymbolVendorMacOSX (const lldb::ModuleSP &module_sp);
virtual
~SymbolVendorMacOSX();
Modified: lldb/trunk/source/Symbol/Block.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Block.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Block.cpp (original)
+++ lldb/trunk/source/Symbol/Block.cpp Thu Feb 23 19:59:29 2012
@@ -158,12 +158,12 @@
sc->block = this;
}
-Module *
+lldb::ModuleSP
Block::CalculateSymbolContextModule ()
{
if (m_parent_scope)
return m_parent_scope->CalculateSymbolContextModule ();
- return NULL;
+ return lldb::ModuleSP();
}
CompileUnit *
@@ -388,7 +388,7 @@
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_SYMBOLS));
if (log)
{
- Module *module = m_parent_scope->CalculateSymbolContextModule();
+ ModuleSP module_sp (m_parent_scope->CalculateSymbolContextModule());
Function *function = m_parent_scope->CalculateSymbolContextFunction();
const addr_t function_file_addr = function->GetAddressRange().GetBaseAddress().GetFileAddress();
const addr_t block_start_addr = function_file_addr + range.GetRangeBase ();
@@ -408,8 +408,8 @@
block_end_addr,
parent_block->GetID(),
function->GetID(),
- module->GetFileSpec().GetDirectory().GetCString(),
- module->GetFileSpec().GetFilename().GetCString());
+ module_sp->GetFileSpec().GetDirectory().GetCString(),
+ module_sp->GetFileSpec().GetFilename().GetCString());
}
else
{
@@ -420,8 +420,8 @@
block_end_addr,
parent_block->GetID(),
function->GetID(),
- module->GetFileSpec().GetDirectory().GetCString(),
- module->GetFileSpec().GetFilename().GetCString());
+ module_sp->GetFileSpec().GetDirectory().GetCString(),
+ module_sp->GetFileSpec().GetFilename().GetCString());
}
}
parent_block->AddRange (range);
Modified: lldb/trunk/source/Symbol/CompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/CompileUnit.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/CompileUnit.cpp (original)
+++ lldb/trunk/source/Symbol/CompileUnit.cpp Thu Feb 23 19:59:29 2012
@@ -16,8 +16,8 @@
using namespace lldb;
using namespace lldb_private;
-CompileUnit::CompileUnit (Module *module, void *user_data, const char *pathname, const lldb::user_id_t cu_sym_id, lldb::LanguageType language) :
- ModuleChild(module),
+CompileUnit::CompileUnit (const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, const lldb::user_id_t cu_sym_id, lldb::LanguageType language) :
+ ModuleChild(module_sp),
FileSpec (pathname, false),
UserID(cu_sym_id),
Language (language),
@@ -28,11 +28,11 @@
m_line_table_ap (),
m_variables()
{
- assert(module != NULL);
+ assert(module_sp);
}
-CompileUnit::CompileUnit (Module *module, void *user_data, const FileSpec &fspec, const lldb::user_id_t cu_sym_id, lldb::LanguageType language) :
- ModuleChild(module),
+CompileUnit::CompileUnit (const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &fspec, const lldb::user_id_t cu_sym_id, lldb::LanguageType language) :
+ ModuleChild(module_sp),
FileSpec (fspec),
UserID(cu_sym_id),
Language (language),
@@ -43,7 +43,7 @@
m_line_table_ap (),
m_variables()
{
- assert(module != NULL);
+ assert(module_sp);
}
CompileUnit::~CompileUnit ()
@@ -57,7 +57,7 @@
GetModule()->CalculateSymbolContext(sc);
}
-Module *
+ModuleSP
CompileUnit::CalculateSymbolContextModule ()
{
return GetModule();
Modified: lldb/trunk/source/Symbol/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Function.cpp (original)
+++ lldb/trunk/source/Symbol/Function.cpp Thu Feb 23 19:59:29 2012
@@ -385,17 +385,17 @@
m_comp_unit->CalculateSymbolContext(sc);
}
-Module *
+ModuleSP
Function::CalculateSymbolContextModule ()
{
- const Section *section = m_range.GetBaseAddress().GetSection();
- if (section)
+ SectionSP section_sp (m_range.GetBaseAddress().GetSection());
+ if (section_sp)
{
- const Section *linked_section = section->GetLinkedSection();
- if (linked_section)
- return linked_section->GetModule();
+ SectionSP linked_section_sp (section_sp->GetLinkedSection());
+ if (linked_section_sp)
+ return linked_section_sp->GetModule();
else
- return section->GetModule();
+ return section_sp->GetModule();
}
return this->GetCompileUnit()->GetModule();
Modified: lldb/trunk/source/Symbol/LineEntry.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/LineEntry.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/LineEntry.cpp (original)
+++ lldb/trunk/source/Symbol/LineEntry.cpp Thu Feb 23 19:59:29 2012
@@ -29,7 +29,7 @@
LineEntry::LineEntry
(
- lldb_private::Section *section,
+ const lldb::SectionSP §ion_sp,
lldb::addr_t section_offset,
lldb::addr_t byte_size,
const FileSpec &_file,
@@ -41,7 +41,7 @@
bool _is_epilogue_begin,
bool _is_terminal_entry
) :
- range(section, section_offset, byte_size),
+ range(section_sp, section_offset, byte_size),
file(_file),
line(_line),
column(_column),
Modified: lldb/trunk/source/Symbol/LineTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/LineTable.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/LineTable.cpp (original)
+++ lldb/trunk/source/Symbol/LineTable.cpp Thu Feb 23 19:59:29 2012
@@ -44,7 +44,7 @@
void
LineTable::AppendLineEntry
(
- SectionSP& section_sp,
+ const lldb::SectionSP& section_sp,
lldb::addr_t section_offset,
uint32_t line,
uint16_t column,
@@ -65,7 +65,7 @@
void
LineTable::InsertLineEntry
(
- SectionSP& section_sp,
+ const SectionSP& section_sp,
lldb::addr_t section_offset,
uint32_t line,
uint16_t column,
@@ -77,14 +77,18 @@
bool is_terminal_entry
)
{
- SectionSP line_section_sp(section_sp);
- const Section *linked_section = line_section_sp->GetLinkedSection();
- if (linked_section)
- {
- section_offset += line_section_sp->GetLinkedOffset();
- line_section_sp = linked_section->GetSharedPointer();
- assert(line_section_sp.get());
+ SectionSP line_section_sp;
+ SectionSP linked_section_sp (section_sp->GetLinkedSection());
+ if (linked_section_sp)
+ {
+ section_offset += section_sp->GetLinkedOffset();
+ line_section_sp = linked_section_sp;
+ }
+ else
+ {
+ line_section_sp = section_sp;
}
+ assert(line_section_sp.get());
uint32_t sect_idx = m_section_list.AddUniqueSection (line_section_sp);
Entry entry(sect_idx, section_offset, line, column, file_idx, is_start_of_statement, is_start_of_basic_block, is_prologue_end, is_epilogue_begin, is_terminal_entry);
@@ -168,7 +172,7 @@
*index_ptr = UINT32_MAX;
bool success = false;
- uint32_t sect_idx = m_section_list.FindSectionIndex (so_addr.GetSection());
+ uint32_t sect_idx = m_section_list.FindSectionIndex (so_addr.GetSection().get());
if (sect_idx != UINT32_MAX)
{
Entry search_entry;
@@ -242,7 +246,7 @@
if (idx < m_entries.size())
{
const Entry& entry = m_entries[idx];
- line_entry.range.GetBaseAddress().SetSection(m_section_list.GetSectionAtIndex (entry.sect_idx).get());
+ line_entry.range.GetBaseAddress().SetSection(m_section_list.GetSectionAtIndex (entry.sect_idx));
line_entry.range.GetBaseAddress().SetOffset(entry.sect_offset);
if (!entry.is_terminal_entry && idx + 1 < m_entries.size())
{
@@ -253,7 +257,7 @@
}
else
{
- Address next_line_addr(m_section_list.GetSectionAtIndex (next_entry.sect_idx).get(), next_entry.sect_offset);
+ Address next_line_addr(m_section_list.GetSectionAtIndex (next_entry.sect_idx), next_entry.sect_offset);
line_entry.range.SetByteSize(next_line_addr.GetFileAddress() - line_entry.range.GetBaseAddress().GetFileAddress());
}
}
Modified: lldb/trunk/source/Symbol/ObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ObjectFile.cpp (original)
+++ lldb/trunk/source/Symbol/ObjectFile.cpp Thu Feb 23 19:59:29 2012
@@ -25,17 +25,17 @@
using namespace lldb_private;
ObjectFileSP
-ObjectFile::FindPlugin (Module* module, const FileSpec* file, addr_t file_offset, addr_t file_size, DataBufferSP &file_data_sp)
+ObjectFile::FindPlugin (const lldb::ModuleSP &module_sp, const FileSpec* file, addr_t file_offset, addr_t file_size, DataBufferSP &file_data_sp)
{
- Timer scoped_timer (__PRETTY_FUNCTION__,
- "ObjectFile::FindPlugin (module = %s/%s, file = %p, file_offset = 0x%z8.8x, file_size = 0x%z8.8x)",
- module->GetFileSpec().GetDirectory().AsCString(),
- module->GetFileSpec().GetFilename().AsCString(),
- file, file_offset, file_size);
ObjectFileSP object_file_sp;
- if (module != NULL)
+ if (module_sp)
{
+ Timer scoped_timer (__PRETTY_FUNCTION__,
+ "ObjectFile::FindPlugin (module = %s/%s, file = %p, file_offset = 0x%z8.8x, file_size = 0x%z8.8x)",
+ module_sp->GetFileSpec().GetDirectory().AsCString(),
+ module_sp->GetFileSpec().GetFilename().AsCString(),
+ file, file_offset, file_size);
if (file)
{
// Memory map the entire file contents
@@ -49,7 +49,7 @@
{
// Check for archive file with format "/path/to/archive.a(object.o)"
char path_with_object[PATH_MAX*2];
- module->GetFileSpec().GetPath(path_with_object, sizeof(path_with_object));
+ module_sp->GetFileSpec().GetPath(path_with_object, sizeof(path_with_object));
RegularExpression g_object_regex("(.*)\\(([^\\)]+)\\)$");
if (g_object_regex.Execute (path_with_object, 2))
@@ -64,7 +64,7 @@
file_size = archive_file.GetByteSize();
if (file_size > 0)
{
- module->SetFileSpecAndObjectName (archive_file, ConstString(object.c_str()));
+ module_sp->SetFileSpecAndObjectName (archive_file, ConstString(object.c_str()));
file_data_sp = archive_file.MemoryMapFileContents(file_offset, file_size);
}
}
@@ -80,7 +80,7 @@
ObjectFileCreateInstance create_object_file_callback;
for (idx = 0; (create_object_file_callback = PluginManager::GetObjectFileCreateCallbackAtIndex(idx)) != NULL; ++idx)
{
- object_file_sp.reset (create_object_file_callback(module, file_data_sp, file, file_offset, file_size));
+ object_file_sp.reset (create_object_file_callback(module_sp, file_data_sp, file, file_offset, file_size));
if (object_file_sp.get())
return object_file_sp;
}
@@ -91,7 +91,7 @@
ObjectContainerCreateInstance create_object_container_callback;
for (idx = 0; (create_object_container_callback = PluginManager::GetObjectContainerCreateCallbackAtIndex(idx)) != NULL; ++idx)
{
- std::auto_ptr<ObjectContainer> object_container_ap(create_object_container_callback(module, file_data_sp, file, file_offset, file_size));
+ std::auto_ptr<ObjectContainer> object_container_ap(create_object_container_callback(module_sp, file_data_sp, file, file_offset, file_size));
if (object_container_ap.get())
object_file_sp = object_container_ap->GetObjectFile(file);
@@ -109,20 +109,20 @@
}
ObjectFileSP
-ObjectFile::FindPlugin (Module* module,
+ObjectFile::FindPlugin (const lldb::ModuleSP &module_sp,
const ProcessSP &process_sp,
lldb::addr_t header_addr,
DataBufferSP &file_data_sp)
{
- Timer scoped_timer (__PRETTY_FUNCTION__,
- "ObjectFile::FindPlugin (module = %s/%s, process = %p, header_addr = 0x%llx)",
- module->GetFileSpec().GetDirectory().AsCString(),
- module->GetFileSpec().GetFilename().AsCString(),
- process_sp.get(), header_addr);
ObjectFileSP object_file_sp;
- if (module != NULL)
+ if (module_sp)
{
+ Timer scoped_timer (__PRETTY_FUNCTION__,
+ "ObjectFile::FindPlugin (module = %s/%s, process = %p, header_addr = 0x%llx)",
+ module_sp->GetFileSpec().GetDirectory().AsCString(),
+ module_sp->GetFileSpec().GetFilename().AsCString(),
+ process_sp.get(), header_addr);
uint32_t idx;
// Check if this is a normal object file by iterating through
@@ -130,7 +130,7 @@
ObjectFileCreateMemoryInstance create_callback;
for (idx = 0; (create_callback = PluginManager::GetObjectFileCreateMemoryCallbackAtIndex(idx)) != NULL; ++idx)
{
- object_file_sp.reset (create_callback(module, file_data_sp, process_sp, header_addr));
+ object_file_sp.reset (create_callback(module_sp, file_data_sp, process_sp, header_addr));
if (object_file_sp.get())
return object_file_sp;
}
@@ -142,12 +142,12 @@
return object_file_sp;
}
-ObjectFile::ObjectFile (Module* module,
+ObjectFile::ObjectFile (const lldb::ModuleSP &module_sp,
const FileSpec *file_spec_ptr,
addr_t file_offset,
addr_t file_size,
DataBufferSP& file_data_sp) :
- ModuleChild (module),
+ ModuleChild (module_sp),
m_file (), // This file could be different from the original module's file
m_type (eTypeInvalid),
m_strata (eStrataInvalid),
@@ -169,8 +169,8 @@
{
log->Printf ("%p ObjectFile::ObjectFile () module = %s/%s, file = %s/%s, offset = 0x%8.8llx, size = %llu\n",
this,
- m_module->GetFileSpec().GetDirectory().AsCString(),
- m_module->GetFileSpec().GetFilename().AsCString(),
+ module_sp->GetFileSpec().GetDirectory().AsCString(),
+ module_sp->GetFileSpec().GetFilename().AsCString(),
m_file.GetDirectory().AsCString(),
m_file.GetFilename().AsCString(),
m_offset,
@@ -180,8 +180,8 @@
{
log->Printf ("%p ObjectFile::ObjectFile () module = %s/%s, file = <NULL>, offset = 0x%8.8llx, size = %llu\n",
this,
- m_module->GetFileSpec().GetDirectory().AsCString(),
- m_module->GetFileSpec().GetFilename().AsCString(),
+ module_sp->GetFileSpec().GetDirectory().AsCString(),
+ module_sp->GetFileSpec().GetFilename().AsCString(),
m_offset,
m_length);
}
@@ -189,11 +189,11 @@
}
-ObjectFile::ObjectFile (Module* module,
+ObjectFile::ObjectFile (const lldb::ModuleSP &module_sp,
const ProcessSP &process_sp,
lldb::addr_t header_addr,
DataBufferSP& header_data_sp) :
- ModuleChild (module),
+ ModuleChild (module_sp),
m_file (),
m_type (eTypeInvalid),
m_strata (eStrataInvalid),
@@ -211,8 +211,8 @@
{
log->Printf ("%p ObjectFile::ObjectFile () module = %s/%s, process = %p, header_addr = 0x%llx\n",
this,
- m_module->GetFileSpec().GetDirectory().AsCString(),
- m_module->GetFileSpec().GetFilename().AsCString(),
+ module_sp->GetFileSpec().GetDirectory().AsCString(),
+ module_sp->GetFileSpec().GetFilename().AsCString(),
process_sp.get(),
m_offset);
}
@@ -224,12 +224,13 @@
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_OBJECT));
if (log)
{
+ ModuleSP module_sp (GetModule());
if (m_file)
{
log->Printf ("%p ObjectFile::~ObjectFile () module = %s/%s, file = %s/%s, offset = 0x%8.8llx, size = %llu\n",
this,
- m_module->GetFileSpec().GetDirectory().AsCString(),
- m_module->GetFileSpec().GetFilename().AsCString(),
+ module_sp->GetFileSpec().GetDirectory().AsCString(),
+ module_sp->GetFileSpec().GetFilename().AsCString(),
m_file.GetDirectory().AsCString(),
m_file.GetFilename().AsCString(),
m_offset,
@@ -239,8 +240,8 @@
{
log->Printf ("%p ObjectFile::~ObjectFile () module = %s/%s, file = <NULL>, offset = 0x%8.8llx, size = %llu\n",
this,
- m_module->GetFileSpec().GetDirectory().AsCString(),
- m_module->GetFileSpec().GetFilename().AsCString(),
+ module_sp->GetFileSpec().GetDirectory().AsCString(),
+ module_sp->GetFileSpec().GetFilename().AsCString(),
m_offset,
m_length);
}
@@ -250,7 +251,10 @@
bool
ObjectFile::SetModulesArchitecture (const ArchSpec &new_arch)
{
- return m_module->SetArchitecture (new_arch);
+ ModuleSP module_sp (GetModule());
+ if (module_sp)
+ return module_sp->SetArchitecture (new_arch);
+ return false;
}
AddressClass
@@ -265,10 +269,10 @@
const AddressRange *range_ptr = symbol->GetAddressRangePtr();
if (range_ptr)
{
- const Section *section = range_ptr->GetBaseAddress().GetSection();
- if (section)
+ const SectionSP section_sp (range_ptr->GetBaseAddress().GetSection());
+ if (section_sp)
{
- const SectionType section_type = section->GetType();
+ const SectionType section_type = section_sp->GetType();
switch (section_type)
{
case eSectionTypeInvalid: return eAddressClassUnknown;
Modified: lldb/trunk/source/Symbol/Symbol.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Symbol.cpp (original)
+++ lldb/trunk/source/Symbol/Symbol.cpp Thu Feb 23 19:59:29 2012
@@ -46,7 +46,7 @@
bool is_debug,
bool is_trampoline,
bool is_artificial,
- const Section* section,
+ const lldb::SectionSP §ion_sp,
addr_t offset,
uint32_t size,
uint32_t flags
@@ -63,7 +63,7 @@
m_size_is_synthesized (false),
m_type (type),
m_flags (flags),
- m_addr_range (section, offset, size)
+ m_addr_range (section_sp, offset, size)
{
}
@@ -185,8 +185,7 @@
{
s->Printf("uid={%6u}", m_uid);
- const Section *section = m_addr_range.GetBaseAddress().GetSection();
- if (section != NULL)
+ if (m_addr_range.GetBaseAddress().GetSection())
{
if (m_addr_range.GetBaseAddress().IsSectionOffset())
{
@@ -232,8 +231,8 @@
m_is_external ? 'X' : ' ',
GetTypeAsString());
- const Section *section = m_addr_range.GetBaseAddress().GetSection();
- if (section != NULL)
+ SectionSP section_sp (m_addr_range.GetBaseAddress().GetSection());
+ if (section_sp)
{
if (!m_addr_range.GetBaseAddress().Dump(s, NULL, Address::DumpStyleFileAddress))
s->Printf("%*s", 18, "");
@@ -272,11 +271,11 @@
if (!m_type_data_resolved)
{
m_type_data_resolved = true;
- Module *module = m_addr_range.GetBaseAddress().GetModulePtr();
+ ModuleSP module_sp (m_addr_range.GetBaseAddress().GetModule());
SymbolContext sc;
- if (module && module->ResolveSymbolContextForAddress (m_addr_range.GetBaseAddress(),
- eSymbolContextLineEntry,
- sc))
+ if (module_sp && module_sp->ResolveSymbolContextForAddress (m_addr_range.GetBaseAddress(),
+ eSymbolContextLineEntry,
+ sc))
{
m_type_data = sc.line_entry.range.GetByteSize();
}
@@ -294,8 +293,7 @@
void
Symbol::SetValue(addr_t value)
{
- m_addr_range.GetBaseAddress().SetSection(NULL);
- m_addr_range.GetBaseAddress().SetOffset(value);
+ m_addr_range.GetBaseAddress().SetRawAddress(value);
}
@@ -355,18 +353,18 @@
sc->symbol = this;
const AddressRange *range = GetAddressRangePtr();
if (range)
- sc->module_sp = range->GetBaseAddress().GetModuleSP ();
+ sc->module_sp = range->GetBaseAddress().GetModule();
else
sc->module_sp.reset();
}
-Module *
+ModuleSP
Symbol::CalculateSymbolContextModule ()
{
const AddressRange *range = GetAddressRangePtr();
if (range)
- return range->GetBaseAddress().GetModulePtr ();
- return NULL;
+ return range->GetBaseAddress().GetModule();
+ return ModuleSP();
}
Symbol *
@@ -383,11 +381,11 @@
const AddressRange *range = GetAddressRangePtr();
if (range)
{
- Module *module = range->GetBaseAddress().GetModulePtr ();
- if (module)
+ ModuleSP module_sp (range->GetBaseAddress().GetModule());
+ if (module_sp)
{
dumped_module = true;
- module->DumpSymbolContext(s);
+ module_sp->DumpSymbolContext(s);
}
}
if (dumped_module)
Modified: lldb/trunk/source/Symbol/SymbolVendor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolVendor.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/SymbolVendor.cpp (original)
+++ lldb/trunk/source/Symbol/SymbolVendor.cpp Thu Feb 23 19:59:29 2012
@@ -30,7 +30,7 @@
// also allow for finding separate debug information files.
//----------------------------------------------------------------------
SymbolVendor*
-SymbolVendor::FindPlugin (Module* module)
+SymbolVendor::FindPlugin (const lldb::ModuleSP &module_sp)
{
std::auto_ptr<SymbolVendor> instance_ap;
//----------------------------------------------------------------------
@@ -39,7 +39,7 @@
SymbolVendorCreateInstance create_callback;
for (uint32_t idx = 0; (create_callback = PluginManager::GetSymbolVendorCreateCallbackAtIndex(idx)) != NULL; ++idx)
{
- instance_ap.reset(create_callback(module));
+ instance_ap.reset(create_callback(module_sp));
if (instance_ap.get())
{
@@ -53,10 +53,10 @@
}
// The default implementation just tries to create debug information using the
// file representation for the module.
- instance_ap.reset(new SymbolVendor(module));
+ instance_ap.reset(new SymbolVendor(module_sp));
if (instance_ap.get())
{
- ObjectFile *objfile = module->GetObjectFile();
+ ObjectFile *objfile = module_sp->GetObjectFile();
if (objfile)
instance_ap->AddSymbolFileRepresentation(objfile->shared_from_this());
}
@@ -66,8 +66,8 @@
//----------------------------------------------------------------------
// SymbolVendor constructor
//----------------------------------------------------------------------
-SymbolVendor::SymbolVendor(Module *module) :
- ModuleChild(module),
+SymbolVendor::SymbolVendor(const lldb::ModuleSP &module_sp) :
+ ModuleChild (module_sp),
m_mutex (Mutex::eMutexTypeRecursive),
m_type_list(),
m_compile_units(),
Modified: lldb/trunk/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Thu Feb 23 19:59:29 2012
@@ -35,7 +35,11 @@
SymbolFileType::GetType ()
{
if (!m_type_sp)
- m_type_sp = m_symbol_file.ResolveTypeUID (GetID())->shared_from_this();
+ {
+ Type *resolved_type = m_symbol_file.ResolveTypeUID (GetID());
+ if (resolved_type)
+ m_type_sp = resolved_type->shared_from_this();
+ }
return m_type_sp.get();
}
Modified: lldb/trunk/source/Symbol/Variable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Variable.cpp (original)
+++ lldb/trunk/source/Symbol/Variable.cpp Thu Feb 23 19:59:29 2012
@@ -146,8 +146,9 @@
ABI *abi = NULL;
if (m_owner_scope)
{
- Module *module = m_owner_scope->CalculateSymbolContextModule();
- abi = ABI::FindPlugin (module->GetArchitecture()).get();
+ ModuleSP module_sp (m_owner_scope->CalculateSymbolContextModule());
+ if (module_sp)
+ abi = ABI::FindPlugin (module_sp->GetArchitecture()).get();
}
m_location.GetDescription(s, lldb::eDescriptionLevelBrief, loclist_base_addr, abi);
}
@@ -243,7 +244,7 @@
{
SymbolContext sc;
CalculateSymbolContext(&sc);
- if (sc.module_sp.get() == address.GetModulePtr())
+ if (sc.module_sp == address.GetModule())
{
// Is the variable is described by a single location?
if (!m_location.IsLocationList())
@@ -480,13 +481,14 @@
{
SymbolContext sc;
CalculateSymbolContext(&sc);
- if (sc.module_sp.get() == address.GetModulePtr())
+ if (sc.module_sp == address.GetModule())
{
ABI *abi = NULL;
if (m_owner_scope)
{
- Module *module = m_owner_scope->CalculateSymbolContextModule();
- abi = ABI::FindPlugin (module->GetArchitecture()).get();
+ ModuleSP module_sp (m_owner_scope->CalculateSymbolContextModule());
+ if (module_sp)
+ abi = ABI::FindPlugin (module_sp->GetArchitecture()).get();
}
const addr_t file_addr = address.GetFileAddress();
Modified: lldb/trunk/source/Target/SectionLoadList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/SectionLoadList.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Target/SectionLoadList.cpp (original)
+++ lldb/trunk/source/Target/SectionLoadList.cpp Thu Feb 23 19:59:29 2012
@@ -94,15 +94,15 @@
{
if (section != ats_pos->second)
{
- Module *module = section->GetModule();
- if (module)
+ ModuleSP module_sp (section->GetModule());
+ if (module_sp)
{
- module->ReportWarning ("address 0x%16.16llx maps to more than one section: %s.%s and %s.%s",
- load_addr,
- module->GetFileSpec().GetFilename().GetCString(),
- section->GetName().GetCString(),
- ats_pos->second->GetModule()->GetFileSpec().GetFilename().GetCString(),
- ats_pos->second->GetName().GetCString());
+ module_sp->ReportWarning ("address 0x%16.16llx maps to more than one section: %s.%s and %s.%s",
+ load_addr,
+ module_sp->GetFileSpec().GetFilename().GetCString(),
+ section->GetName().GetCString(),
+ ats_pos->second->GetModule()->GetFileSpec().GetFilename().GetCString(),
+ ats_pos->second->GetName().GetCString());
}
}
ats_pos->second = section;
Modified: lldb/trunk/source/Target/StackFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrame.cpp (original)
+++ lldb/trunk/source/Target/StackFrame.cpp Thu Feb 23 19:59:29 2012
@@ -50,7 +50,7 @@
m_concrete_frame_index (unwind_frame_index),
m_reg_context_sp (),
m_id (pc, cfa, NULL),
- m_frame_code_addr (NULL, pc),
+ m_frame_code_addr (pc),
m_sc (),
m_flags (),
m_frame_base (),
@@ -78,7 +78,7 @@
m_concrete_frame_index (unwind_frame_index),
m_reg_context_sp (reg_context_sp),
m_id (pc, cfa, NULL),
- m_frame_code_addr (NULL, pc),
+ m_frame_code_addr (pc),
m_sc (),
m_flags (),
m_frame_base (),
@@ -135,19 +135,18 @@
m_flags.Set (eSymbolContextTarget);
}
- Module *pc_module = pc_addr.GetModulePtr();
- if (m_sc.module_sp.get() == NULL || m_sc.module_sp.get() != pc_module)
+ ModuleSP pc_module_sp (pc_addr.GetModule());
+ if (!m_sc.module_sp || m_sc.module_sp != pc_module_sp)
{
- if (pc_module)
+ if (pc_module_sp)
{
- m_sc.module_sp = pc_module->shared_from_this();
+ m_sc.module_sp = pc_module_sp;
m_flags.Set (eSymbolContextModule);
}
else
{
m_sc.module_sp.reset();
}
-
}
}
@@ -219,16 +218,11 @@
{
if (m_frame_code_addr.SetOpcodeLoadAddress (m_frame_code_addr.GetOffset(), target_sp.get()))
{
- const Section *section = m_frame_code_addr.GetSection();
- if (section)
+ ModuleSP module_sp (m_frame_code_addr.GetModule());
+ if (module_sp)
{
- Module *module = section->GetModule();
- if (module)
- {
- m_sc.module_sp = module->shared_from_this();
- if (m_sc.module_sp)
- m_flags.Set(eSymbolContextModule);
- }
+ m_sc.module_sp = module_sp;
+ m_flags.Set(eSymbolContextModule);
}
}
}
@@ -240,8 +234,7 @@
void
StackFrame::ChangePC (addr_t pc)
{
- m_frame_code_addr.SetOffset(pc);
- m_frame_code_addr.SetSection(NULL);
+ m_frame_code_addr.SetRawAddress(pc);
m_sc.Clear();
m_flags.Reset(0);
ThreadSP thread_sp (GetThread());
Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Thu Feb 23 19:59:29 2012
@@ -986,30 +986,33 @@
size_t
Target::ReadMemoryFromFileCache (const Address& addr, void *dst, size_t dst_len, Error &error)
{
- const Section *section = addr.GetSection();
- if (section && section->GetModule())
+ SectionSP section_sp (addr.GetSection());
+ if (section_sp)
{
- ObjectFile *objfile = section->GetModule()->GetObjectFile();
- if (objfile)
+ ModuleSP module_sp (section_sp->GetModule());
+ if (module_sp)
{
- size_t bytes_read = objfile->ReadSectionData (section,
- addr.GetOffset(),
- dst,
- dst_len);
- if (bytes_read > 0)
- return bytes_read;
+ ObjectFile *objfile = section_sp->GetModule()->GetObjectFile();
+ if (objfile)
+ {
+ size_t bytes_read = objfile->ReadSectionData (section_sp.get(),
+ addr.GetOffset(),
+ dst,
+ dst_len);
+ if (bytes_read > 0)
+ return bytes_read;
+ else
+ error.SetErrorStringWithFormat("error reading data from section %s", section_sp->GetName().GetCString());
+ }
else
- error.SetErrorStringWithFormat("error reading data from section %s", section->GetName().GetCString());
+ error.SetErrorString("address isn't from a object file");
}
else
- {
- error.SetErrorString("address isn't from a object file");
- }
+ error.SetErrorString("address isn't in a module");
}
else
- {
error.SetErrorString("address doesn't contain a section that points to a section in a object file");
- }
+
return 0;
}
@@ -1070,12 +1073,12 @@
if (load_addr == LLDB_INVALID_ADDRESS)
{
- Module *addr_module = resolved_addr.GetModulePtr();
- if (addr_module && addr_module->GetFileSpec())
+ ModuleSP addr_module_sp (resolved_addr.GetModule());
+ if (addr_module_sp && addr_module_sp->GetFileSpec())
error.SetErrorStringWithFormat("%s[0x%llx] can't be resolved, %s in not currently loaded",
- addr_module->GetFileSpec().GetFilename().AsCString(),
+ addr_module_sp->GetFileSpec().GetFilename().AsCString(),
resolved_addr.GetFileAddress(),
- addr_module->GetFileSpec().GetFilename().AsCString());
+ addr_module_sp->GetFileSpec().GetFilename().AsCString());
else
error.SetErrorStringWithFormat("0x%llx can't be resolved", resolved_addr.GetFileAddress());
}
Modified: lldb/trunk/source/Target/ThreadPlanTracer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanTracer.cpp?rev=151336&r1=151335&r2=151336&view=diff
==============================================================================
--- lldb/trunk/source/Target/ThreadPlanTracer.cpp (original)
+++ lldb/trunk/source/Target/ThreadPlanTracer.cpp Thu Feb 23 19:59:29 2012
@@ -205,7 +205,7 @@
if (addr_valid)
disassembler->DecodeInstructions (pc_addr, extractor, 0, 1, false);
else
- disassembler->DecodeInstructions (Address (NULL, pc), extractor, 0, 1, false);
+ disassembler->DecodeInstructions (Address (pc), extractor, 0, 1, false);
InstructionList &instruction_list = disassembler->GetInstructionList();
const uint32_t max_opcode_byte_size = instruction_list.GetMaxOpcocdeByteSize();
More information about the lldb-commits
mailing list