diff options
Diffstat (limited to 'lldb/source/Plugins/LanguageRuntime')
3 files changed, 36 insertions, 55 deletions
diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp index 0d9d0bcf6a3..0dca2eab032 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp @@ -64,7 +64,7 @@ AppleObjCRuntime::GetObjectDescription (Stream &str, ValueObject &object) } bool -AppleObjCRuntime::GetObjectDescription (Stream &str, Value &value, ExecutionContextScope *exe_scope) +AppleObjCRuntime::GetObjectDescription (Stream &strm, Value &value, ExecutionContextScope *exe_scope) { if (!m_read_objc_library) return false; @@ -88,7 +88,7 @@ AppleObjCRuntime::GetObjectDescription (Stream &str, Value &value, ExecutionCont clang::QualType value_type = clang::QualType::getFromOpaquePtr (value.GetClangType()); if (!value_type->isObjCObjectPointerType()) { - str.Printf ("Value doesn't point to an ObjC object.\n"); + strm.Printf ("Value doesn't point to an ObjC object.\n"); return false; } } @@ -138,35 +138,22 @@ AppleObjCRuntime::GetObjectDescription (Stream &str, Value &value, ExecutionCont ret); if (results != eExecutionCompleted) { - str.Printf("Error evaluating Print Object function: %d.\n", results); + strm.Printf("Error evaluating Print Object function: %d.\n", results); return false; } addr_t result_ptr = ret.GetScalar().ULongLong(LLDB_INVALID_ADDRESS); - // FIXME: poor man's strcpy - we should have a "read memory as string interface... - - Error error; - std::vector<char> desc; - while (1) + char buf[512]; + size_t cstr_len = 0; + size_t curr_len = sizeof(buf); + while (curr_len == sizeof(buf)) { - char byte = '\0'; - if (exe_ctx.process->ReadMemory(result_ptr + desc.size(), &byte, 1, error) != 1) - break; - - desc.push_back(byte); - - if (byte == '\0') - break; + curr_len = exe_ctx.process->ReadCStringFromMemory(result_ptr + cstr_len, buf, sizeof(buf)); + strm.Write (buf, curr_len); + cstr_len += curr_len; } - - if (!desc.empty()) - { - str.PutCString(&desc.front()); - return true; - } - return false; - + return cstr_len > 0; } Address * diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 4d315f5c186..fb05f118d04 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -220,9 +220,9 @@ AppleObjCRuntimeV2::RunFunctionToFindClassName(lldb::addr_t object_addr, Thread bool AppleObjCRuntimeV2::GetDynamicTypeAndAddress (ValueObject &in_value, - lldb::DynamicValueType use_dynamic, - TypeAndOrName &class_type_or_name, - Address &address) + lldb::DynamicValueType use_dynamic, + TypeAndOrName &class_type_or_name, + Address &address) { // The Runtime is attached to a particular process, you shouldn't pass in a value from another process. assert (in_value.GetUpdatePoint().GetProcess() == m_process); @@ -244,9 +244,11 @@ AppleObjCRuntimeV2::GetDynamicTypeAndAddress (ValueObject &in_value, Target *target = m_process->CalculateTarget(); char memory_buffer[16]; - DataExtractor data(memory_buffer, sizeof(memory_buffer), - m_process->GetByteOrder(), - m_process->GetAddressByteSize()); + DataExtractor data (memory_buffer, + sizeof(memory_buffer), + m_process->GetByteOrder(), + m_process->GetAddressByteSize()); + size_t address_byte_size = m_process->GetAddressByteSize(); Error error; size_t bytes_read = m_process->ReadMemory (original_ptr, @@ -258,10 +260,10 @@ AppleObjCRuntimeV2::GetDynamicTypeAndAddress (ValueObject &in_value, return false; } - uint32_t offset_ptr = 0; - lldb::addr_t isa_addr = data.GetAddress (&offset_ptr); + uint32_t offset = 0; + lldb::addr_t isa_addr = data.GetAddress (&offset); - if (offset_ptr == 0) + if (offset == 0) return false; // Make sure the class address is readable, otherwise this is not a good object: 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) |