diff options
author | Greg Clayton <gclayton@apple.com> | 2011-05-22 22:46:53 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-05-22 22:46:53 +0000 |
commit | f3ef3d2af95e8cd20bb9bd9aeceb24b4bf8107ca (patch) | |
tree | 1614e0a38827a33bfae37302a3567c9cec8a391b /lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp | |
parent | 5c51177981f6e482dbf2a99700fa8bc801f53401 (diff) | |
download | bcm5719-llvm-f3ef3d2af95e8cd20bb9bd9aeceb24b4bf8107ca.tar.gz bcm5719-llvm-f3ef3d2af95e8cd20bb9bd9aeceb24b4bf8107ca.zip |
Added new lldb_private::Process memory read/write functions to stop a bunch
of duplicated code from appearing all over LLDB:
lldb::addr_t
Process::ReadPointerFromMemory (lldb::addr_t vm_addr, Error &error);
bool
Process::WritePointerToMemory (lldb::addr_t vm_addr, lldb::addr_t ptr_value, Error &error);
size_t
Process::ReadScalarIntegerFromMemory (lldb::addr_t addr, uint32_t byte_size, bool is_signed, Scalar &scalar, Error &error);
size_t
Process::WriteScalarToMemory (lldb::addr_t vm_addr, const Scalar &scalar, uint32_t size, Error &error);
in lldb_private::Process the following functions were renamed:
From:
uint64_t
Process::ReadUnsignedInteger (lldb::addr_t load_addr,
size_t byte_size,
Error &error);
To:
uint64_t
Process::ReadUnsignedIntegerFromMemory (lldb::addr_t load_addr,
size_t byte_size,
uint64_t fail_value,
Error &error);
Cleaned up a lot of code that was manually doing what the above functions do
to use the functions listed above.
Added the ability to get a scalar value as a buffer that can be written down
to a process (byte swapping the Scalar value if needed):
uint32_t
Scalar::GetAsMemoryData (void *dst,
uint32_t dst_len,
lldb::ByteOrder dst_byte_order,
Error &error) const;
The "dst_len" can be smaller that the size of the scalar and the least
significant bytes will be written. "dst_len" can also be larger and the
most significant bytes will be padded with zeroes.
Centralized the code that adds or removes address bits for callable and opcode
addresses into lldb_private::Target:
lldb::addr_t
Target::GetCallableLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
lldb::addr_t
Target::GetOpcodeLoadAddress (lldb::addr_t load_addr, AddressClass addr_class) const;
All necessary lldb_private::Address functions now use the target versions so
changes should only need to happen in one place if anything needs updating.
Fixed up a lot of places that were calling :
addr_t
Address::GetLoadAddress(Target*);
to call the Address::GetCallableLoadAddress() or Address::GetOpcodeLoadAddress()
as needed. There were many places in the breakpoint code where things could
go wrong for ARM if these weren't used.
llvm-svn: 131878
Diffstat (limited to 'lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp')
-rw-r--r-- | lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp index 8d402cfff42..c5b1ddbacd4 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -340,8 +340,8 @@ AppleObjCTrampolineHandler::AppleObjCVTables::InitializeVTableSymbols () if (m_objc_module_sp) { ConstString trampoline_name ("gdb_objc_trampolines"); - const Symbol *trampoline_symbol = m_objc_module_sp->FindFirstSymbolWithNameAndType(trampoline_name, - eSymbolTypeData); + const Symbol *trampoline_symbol = m_objc_module_sp->FindFirstSymbolWithNameAndType (trampoline_name, + eSymbolTypeData); if (trampoline_symbol != NULL) { if (!trampoline_symbol->GetValue().IsValid()) @@ -353,18 +353,17 @@ AppleObjCTrampolineHandler::AppleObjCVTables::InitializeVTableSymbols () // Next look up the "changed" symbol and set a breakpoint on that... ConstString changed_name ("gdb_objc_trampolines_changed"); - const Symbol *changed_symbol = m_objc_module_sp->FindFirstSymbolWithNameAndType(changed_name, - eSymbolTypeCode); + const Symbol *changed_symbol = m_objc_module_sp->FindFirstSymbolWithNameAndType (changed_name, + eSymbolTypeCode); if (changed_symbol != NULL) { if (!changed_symbol->GetValue().IsValid()) return false; - lldb::addr_t changed_addr = changed_symbol->GetValue().GetLoadAddress(&target); + lldb::addr_t changed_addr = changed_symbol->GetValue().GetOpcodeLoadAddress (&target); if (changed_addr != LLDB_INVALID_ADDRESS) { - BreakpointSP trampolines_changed_bp_sp = target.CreateBreakpoint (changed_addr, - true); + BreakpointSP trampolines_changed_bp_sp = target.CreateBreakpoint (changed_addr, true); if (trampolines_changed_bp_sp != NULL) { m_trampolines_changed_bp_id = trampolines_changed_bp_sp->GetID(); @@ -427,18 +426,11 @@ AppleObjCTrampolineHandler::AppleObjCVTables::ReadRegions () m_regions.clear(); if (!InitializeVTableSymbols()) return false; - char memory_buffer[8]; - DataExtractor data(memory_buffer, sizeof(memory_buffer), - m_process_sp->GetByteOrder(), - m_process_sp->GetAddressByteSize()); Error error; - size_t bytes_read = m_process_sp->ReadMemory (m_trampoline_header, memory_buffer, m_process_sp->GetAddressByteSize(), error); - if (bytes_read != m_process_sp->GetAddressByteSize()) - return false; - - uint32_t offset_ptr = 0; - lldb::addr_t region_addr = data.GetPointer(&offset_ptr); - return ReadRegions (region_addr); + lldb::addr_t region_addr = m_process_sp->ReadPointerFromMemory (m_trampoline_header, error); + if (error.Success()) + return ReadRegions (region_addr); + return false; } bool @@ -535,13 +527,13 @@ AppleObjCTrampolineHandler::AppleObjCTrampolineHandler (ProcessSP process_sp, Mo const Symbol *msg_forward_stret = m_objc_module_sp->FindFirstSymbolWithNameAndType (msg_forward_stret_name, eSymbolTypeCode); if (class_getMethodImplementation) - m_impl_fn_addr = class_getMethodImplementation->GetValue().GetLoadAddress(target); + m_impl_fn_addr = class_getMethodImplementation->GetValue().GetOpcodeLoadAddress (target); if (class_getMethodImplementation_stret) - m_impl_stret_fn_addr = class_getMethodImplementation_stret->GetValue().GetLoadAddress(target); + m_impl_stret_fn_addr = class_getMethodImplementation_stret->GetValue().GetOpcodeLoadAddress (target); if (msg_forward) - m_msg_forward_addr = msg_forward->GetValue().GetLoadAddress(target); + m_msg_forward_addr = msg_forward->GetValue().GetOpcodeLoadAddress(target); if (msg_forward_stret) - m_msg_forward_stret_addr = msg_forward_stret->GetValue().GetLoadAddress(target); + m_msg_forward_stret_addr = msg_forward_stret->GetValue().GetOpcodeLoadAddress(target); // FIXME: Do some kind of logging here. if (m_impl_fn_addr == LLDB_INVALID_ADDRESS || m_impl_stret_fn_addr == LLDB_INVALID_ADDRESS) |