[Lldb-commits] [lldb] r191826 - Fix endianness issue with POSIX dyld plugin
Ed Maste
emaste at freebsd.org
Wed Oct 2 07:14:05 PDT 2013
Author: emaste
Date: Wed Oct 2 09:14:05 2013
New Revision: 191826
URL: http://llvm.org/viewvc/llvm-project?rev=191826&view=rev
Log:
Fix endianness issue with POSIX dyld plugin
To support cross-endian and big-endian debugging avoid copying target
memory directly into host variables.
Modified:
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp?rev=191826&r1=191825&r2=191826&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp Wed Oct 2 09:14:05 2013
@@ -30,17 +30,14 @@ ResolveRendezvousAddress(Process *proces
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
}
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(add
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);
Modified: lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h?rev=191826&r1=191825&r2=191826&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h (original)
+++ lldb/trunk/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h Wed Oct 2 09:14:05 2013
@@ -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.
More information about the lldb-commits
mailing list