summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/DynamicLoader
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source/Plugins/DynamicLoader')
-rw-r--r--lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp50
-rw-r--r--lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h13
2 files changed, 38 insertions, 25 deletions
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
index 3e1b52938f4..524e7720533 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
@@ -30,17 +30,14 @@ ResolveRendezvousAddress(Process *process)
addr_t info_location;
addr_t info_addr;
Error error;
- size_t size;
info_location = process->GetImageInfoAddress();
if (info_location == LLDB_INVALID_ADDRESS)
return LLDB_INVALID_ADDRESS;
- info_addr = 0;
- size = process->DoReadMemory(info_location, &info_addr,
- process->GetAddressByteSize(), error);
- if (size != process->GetAddressByteSize() || error.Fail())
+ info_addr = process->ReadPointerFromMemory(info_location, error);
+ if (error.Fail())
return LLDB_INVALID_ADDRESS;
if (info_addr == 0)
@@ -88,19 +85,19 @@ DYLDRendezvous::Resolve()
if (cursor == LLDB_INVALID_ADDRESS)
return false;
- if (!(cursor = ReadMemory(cursor, &info.version, word_size)))
+ if (!(cursor = ReadWord(cursor, &info.version, word_size)))
return false;
- if (!(cursor = ReadMemory(cursor + padding, &info.map_addr, address_size)))
+ if (!(cursor = ReadPointer(cursor + padding, &info.map_addr)))
return false;
- if (!(cursor = ReadMemory(cursor, &info.brk, address_size)))
+ if (!(cursor = ReadPointer(cursor, &info.brk)))
return false;
- if (!(cursor = ReadMemory(cursor, &info.state, word_size)))
+ if (!(cursor = ReadWord(cursor, &info.state, word_size)))
return false;
- if (!(cursor = ReadMemory(cursor + padding, &info.ldbase, address_size)))
+ if (!(cursor = ReadPointer(cursor + padding, &info.ldbase)))
return false;
// The rendezvous was successfully read. Update our internal state.
@@ -234,16 +231,27 @@ DYLDRendezvous::TakeSnapshot(SOEntryList &entry_list)
}
addr_t
-DYLDRendezvous::ReadMemory(addr_t addr, void *dst, size_t size)
+DYLDRendezvous::ReadWord(addr_t addr, uint64_t *dst, size_t size)
{
- size_t bytes_read;
Error error;
- bytes_read = m_process->DoReadMemory(addr, dst, size, error);
- if (bytes_read != size || error.Fail())
+ *dst = m_process->ReadUnsignedIntegerFromMemory(addr, size, 0, error);
+ if (error.Fail())
+ return 0;
+
+ return addr + size;
+}
+
+addr_t
+DYLDRendezvous::ReadPointer(addr_t addr, addr_t *dst)
+{
+ Error error;
+
+ *dst = m_process->ReadPointerFromMemory(addr, error);
+ if (error.Fail())
return 0;
- return addr + bytes_read;
+ return addr + m_process->GetAddressByteSize();
}
std::string
@@ -275,23 +283,21 @@ DYLDRendezvous::ReadStringFromMemory(addr_t addr)
bool
DYLDRendezvous::ReadSOEntryFromMemory(lldb::addr_t addr, SOEntry &entry)
{
- size_t address_size = m_process->GetAddressByteSize();
-
entry.clear();
- if (!(addr = ReadMemory(addr, &entry.base_addr, address_size)))
+ if (!(addr = ReadPointer(addr, &entry.base_addr)))
return false;
- if (!(addr = ReadMemory(addr, &entry.path_addr, address_size)))
+ if (!(addr = ReadPointer(addr, &entry.path_addr)))
return false;
- if (!(addr = ReadMemory(addr, &entry.dyn_addr, address_size)))
+ if (!(addr = ReadPointer(addr, &entry.dyn_addr)))
return false;
- if (!(addr = ReadMemory(addr, &entry.next, address_size)))
+ if (!(addr = ReadPointer(addr, &entry.next)))
return false;
- if (!(addr = ReadMemory(addr, &entry.prev, address_size)))
+ if (!(addr = ReadPointer(addr, &entry.prev)))
return false;
entry.path = ReadStringFromMemory(entry.path_addr);
diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
index 67e7228a38d..5f8b013dd4a 100644
--- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
+++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
@@ -194,12 +194,19 @@ protected:
/// Resolve().
SOEntryList m_removed_soentries;
- /// Reads @p size bytes from the inferiors address space starting at @p
- /// addr.
+ /// Reads an unsigned integer of @p size bytes from the inferior's address
+ /// space starting at @p addr.
///
/// @returns addr + size if the read was successful and false otherwise.
lldb::addr_t
- ReadMemory(lldb::addr_t addr, void *dst, size_t size);
+ ReadWord(lldb::addr_t addr, uint64_t *dst, size_t size);
+
+ /// Reads an address from the inferior's address space starting at @p addr.
+ ///
+ /// @returns addr + target address size if the read was successful and
+ /// 0 otherwise.
+ lldb::addr_t
+ ReadPointer(lldb::addr_t addr, lldb::addr_t *dst);
/// Reads a null-terminated C string from the memory location starting at @p
/// addr.
OpenPOWER on IntegriCloud