diff options
Diffstat (limited to 'lldb/source/Core')
-rw-r--r-- | lldb/source/Core/Address.cpp | 83 | ||||
-rw-r--r-- | lldb/source/Core/AddressRange.cpp | 23 | ||||
-rw-r--r-- | lldb/source/Core/Disassembler.cpp | 16 | ||||
-rw-r--r-- | lldb/source/Core/Section.cpp | 32 | ||||
-rw-r--r-- | lldb/source/Core/Value.cpp | 2 | ||||
-rw-r--r-- | lldb/source/Core/ValueObject.cpp | 10 | ||||
-rw-r--r-- | lldb/source/Core/ValueObjectVariable.cpp | 4 |
7 files changed, 90 insertions, 80 deletions
diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp index 98b56355517..df5a646fa91 100644 --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -11,6 +11,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/Section.h" #include "lldb/Symbol/ObjectFile.h" +#include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" @@ -138,27 +139,30 @@ ReadAddress (ExecutionContextScope *exe_scope, const Address &address, uint32_t addr_t deref_addr = ReadUIntMax64 (exe_scope, address, pointer_size, success); if (success) { - Process *process = exe_scope->CalculateProcess(); - if (process && process->IsAlive()) + ExecutionContext exe_ctx; + exe_scope->Calculate(exe_ctx); + // If we have any sections that are loaded, try and resolve using the + // section load list + if (exe_ctx.target && !exe_ctx.target->GetSectionLoadList().IsEmpty()) { - if (!process->ResolveLoadAddress (deref_addr, deref_so_addr)) - { - deref_so_addr.SetSection(NULL); - deref_so_addr.SetOffset(deref_addr); - } + if (exe_ctx.target->GetSectionLoadList().ResolveLoadAddress (deref_addr, deref_so_addr)) + return true; } else { - Target *target = exe_scope->CalculateTarget(); - if (target == NULL) - return false; - - if (!target->GetImages().ResolveFileAddress(deref_addr, deref_so_addr)) - { - deref_so_addr.SetSection(NULL); - deref_so_addr.SetOffset(deref_addr); - } + // If we were not running, yet able to read an integer, we must + // have a module + Module *module = address.GetModule(); + assert (module); + if (module->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); return true; } return false; @@ -334,27 +338,28 @@ Address::GetFileAddress () const } addr_t -Address::GetLoadAddress (Process *process) const +Address::GetLoadAddress (Target *target) const { - if (m_section != NULL) + if (m_section == NULL) { - if (process) - { - addr_t sect_load_addr = m_section->GetLoadBaseAddress (process); + // No section, we just return the offset since it is the value in this case + return m_offset; + } + + if (target) + { + addr_t sect_load_addr = m_section->GetLoadBaseAddress (target); - if (sect_load_addr != LLDB_INVALID_ADDRESS) - { - // We have a valid file range, so we can return the file based - // address by adding the file base address to our offset - return sect_load_addr + m_offset; - } + if (sect_load_addr != LLDB_INVALID_ADDRESS) + { + // We have a valid file range, so we can return the file based + // address by adding the file base address to our offset + return sect_load_addr + m_offset; } - // The section isn't resolved or no process was supplied so we can't - // return a valid file address. - return LLDB_INVALID_ADDRESS; } - // No section, we just return the offset since it is the value in this case - return m_offset; + // The section isn't resolved or no process was supplied so we can't + // return a valid file address. + return LLDB_INVALID_ADDRESS; } bool @@ -424,7 +429,7 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum case DumpStyleLoadAddress: { - addr_t load_addr = GetLoadAddress (process); + addr_t load_addr = GetLoadAddress (target); if (load_addr == LLDB_INVALID_ADDRESS) { if (fallback_style != DumpStyleInvalid) @@ -440,7 +445,7 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum if (IsSectionOffset()) { lldb::AddressType addr_type = eAddressTypeLoad; - addr_t addr = GetLoadAddress (process); + addr_t addr = GetLoadAddress (target); if (addr == LLDB_INVALID_ADDRESS) { addr = GetFileAddress(); @@ -670,7 +675,7 @@ Address::Dump (Stream *s, ExecutionContextScope *exe_scope, DumpStyle style, Dum if (sc.symbol->GetAddressRangePtr() && sc.symbol->GetAddressRangePtr()->GetBaseAddress().GetSection() != GetSection()) sc.symbol = NULL; } - sc.GetDescription(s, eDescriptionLevelBrief, process); + sc.GetDescription(s, eDescriptionLevelBrief, target); } } if (fallback_style != DumpStyleInvalid) @@ -733,11 +738,11 @@ Address::CompareFileAddress (const Address& a, const Address& b) int -Address::CompareLoadAddress (const Address& a, const Address& b, Process *process) +Address::CompareLoadAddress (const Address& a, const Address& b, Target *target) { - assert (process != NULL); - addr_t a_load_addr = a.GetLoadAddress (process); - addr_t b_load_addr = b.GetLoadAddress (process); + assert (target != NULL); + addr_t a_load_addr = a.GetLoadAddress (target); + addr_t b_load_addr = b.GetLoadAddress (target); if (a_load_addr < b_load_addr) return -1; if (a_load_addr > b_load_addr) diff --git a/lldb/source/Core/AddressRange.cpp b/lldb/source/Core/AddressRange.cpp index d84a4e8dfa3..b5ed92defd5 100644 --- a/lldb/source/Core/AddressRange.cpp +++ b/lldb/source/Core/AddressRange.cpp @@ -11,6 +11,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/Stream.h" #include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -96,15 +97,15 @@ AddressRange::ContainsFileAddress (addr_t file_addr) const bool -AddressRange::ContainsLoadAddress (const Address &addr, Process *process) const +AddressRange::ContainsLoadAddress (const Address &addr, Target *target) const { if (addr.GetSection() == m_base_addr.GetSection()) return (addr.GetOffset() - m_base_addr.GetOffset()) < GetByteSize(); - addr_t load_base_addr = GetBaseAddress().GetLoadAddress(process); + addr_t load_base_addr = GetBaseAddress().GetLoadAddress(target); if (load_base_addr == LLDB_INVALID_ADDRESS) return false; - addr_t load_addr = addr.GetLoadAddress(process); + addr_t load_addr = addr.GetLoadAddress(target); if (load_addr == LLDB_INVALID_ADDRESS) return false; @@ -115,12 +116,12 @@ AddressRange::ContainsLoadAddress (const Address &addr, Process *process) const } bool -AddressRange::ContainsLoadAddress (addr_t load_addr, Process *process) const +AddressRange::ContainsLoadAddress (addr_t load_addr, Target *target) const { if (load_addr == LLDB_INVALID_ADDRESS) return false; - addr_t load_base_addr = GetBaseAddress().GetLoadAddress(process); + addr_t load_base_addr = GetBaseAddress().GetLoadAddress(target); if (load_base_addr == LLDB_INVALID_ADDRESS) return false; @@ -138,12 +139,12 @@ AddressRange::Clear() } bool -AddressRange::Dump(Stream *s, Process *process, Address::DumpStyle style, Address::DumpStyle fallback_style) const +AddressRange::Dump(Stream *s, Target *target, Address::DumpStyle style, Address::DumpStyle fallback_style) const { addr_t vmaddr = LLDB_INVALID_ADDRESS; int addr_size = sizeof (addr_t); - if (process) - addr_size = process->GetAddressByteSize (); + if (target && target->GetProcessSP()) + addr_size = target->GetProcessSP()->GetAddressByteSize (); bool show_module = false; switch (style) @@ -153,7 +154,7 @@ AddressRange::Dump(Stream *s, Process *process, Address::DumpStyle style, Addres case Address::DumpStyleSectionNameOffset: case Address::DumpStyleSectionPointerOffset: s->PutChar ('['); - m_base_addr.Dump(s, process, style, fallback_style); + m_base_addr.Dump(s, target, style, fallback_style); s->PutChar ('-'); s->Address (m_base_addr.GetOffset() + GetByteSize(), addr_size); s->PutChar (')'); @@ -168,7 +169,7 @@ AddressRange::Dump(Stream *s, Process *process, Address::DumpStyle style, Addres break; case Address::DumpStyleLoadAddress: - vmaddr = m_base_addr.GetLoadAddress(process); + vmaddr = m_base_addr.GetLoadAddress(target); break; } @@ -185,7 +186,7 @@ AddressRange::Dump(Stream *s, Process *process, Address::DumpStyle style, Addres } else if (fallback_style != Address::DumpStyleInvalid) { - return Dump(s, process, fallback_style, Address::DumpStyleInvalid); + return Dump(s, target, fallback_style, Address::DumpStyleInvalid); } return false; diff --git a/lldb/source/Core/Disassembler.cpp b/lldb/source/Core/Disassembler.cpp index 18786bd05ed..40d8d300682 100644 --- a/lldb/source/Core/Disassembler.cpp +++ b/lldb/source/Core/Disassembler.cpp @@ -155,17 +155,19 @@ Disassembler::Disassemble // try and resolve it to something if (range.GetBaseAddress().IsSectionOffset() == false) { - if (process && process->IsAlive()) + if (exe_ctx.target) { - process->ResolveLoadAddress (range.GetBaseAddress().GetOffset(), range.GetBaseAddress()); - } - else if (exe_ctx.target) - { - exe_ctx.target->GetImages().ResolveFileAddress (range.GetBaseAddress().GetOffset(), range.GetBaseAddress()); + if (exe_ctx.target->GetSectionLoadList().IsEmpty()) + { + exe_ctx.target->GetImages().ResolveFileAddress (range.GetBaseAddress().GetOffset(), range.GetBaseAddress()); + } + else + { + exe_ctx.target->GetSectionLoadList().ResolveLoadAddress (range.GetBaseAddress().GetOffset(), range.GetBaseAddress()); + } } } - DataExtractor data; size_t bytes_disassembled = disassembler->ParseInstructions (&exe_ctx, range, data); if (bytes_disassembled == 0) diff --git a/lldb/source/Core/Section.cpp b/lldb/source/Core/Section.cpp index b506879d50a..f4e8800222c 100644 --- a/lldb/source/Core/Section.cpp +++ b/lldb/source/Core/Section.cpp @@ -10,7 +10,7 @@ #include "lldb/Core/Section.h" #include "lldb/Core/Module.h" #include "lldb/Symbol/ObjectFile.h" -#include "lldb/Target/Process.h" +#include "lldb/Target/Target.h" using namespace lldb; using namespace lldb_private; @@ -112,23 +112,23 @@ Section::GetLinkedFileAddress () const addr_t -Section::GetLoadBaseAddress (Process *process) const +Section::GetLoadBaseAddress (Target *target) const { addr_t load_base_addr = LLDB_INVALID_ADDRESS; if (m_linked_section) { - load_base_addr = m_linked_section->GetLoadBaseAddress(process) + m_linked_offset; + load_base_addr = m_linked_section->GetLoadBaseAddress(target) + m_linked_offset; } else if (m_parent) { - load_base_addr = m_parent->GetLoadBaseAddress (process); + load_base_addr = m_parent->GetLoadBaseAddress (target); if (load_base_addr != LLDB_INVALID_ADDRESS) load_base_addr += GetOffset(); } else { - load_base_addr = process->GetSectionLoadAddress(this); + load_base_addr = target->GetSectionLoadList().GetSectionLoadAddress (this); } return load_base_addr; @@ -222,7 +222,7 @@ Section::Compare (const Section& a, const Section& b) void -Section::Dump(Stream *s, Process *process) const +Section::Dump(Stream *s, Target *target) const { s->Printf("%.*p: ", (int)sizeof(void*) * 2, this); s->Indent(); @@ -234,12 +234,12 @@ Section::Dump(Stream *s, Process *process) const s->Printf("%39s", ""); else { - if (process) - addr = GetLoadBaseAddress (process); + if (target) + addr = GetLoadBaseAddress (target); if (addr == LLDB_INVALID_ADDRESS) { - if (process) + if (target) resolved = false; addr = GetFileAddress(); } @@ -258,16 +258,16 @@ Section::Dump(Stream *s, Process *process) const { addr = LLDB_INVALID_ADDRESS; - if (process) + if (target) { - addr = m_linked_section->GetLoadBaseAddress(process); + addr = m_linked_section->GetLoadBaseAddress(target); if (addr != LLDB_INVALID_ADDRESS) addr += m_linked_offset; } if (addr == LLDB_INVALID_ADDRESS) { - if (process) + if (target) resolved = false; addr = m_linked_section->GetFileAddress() + m_linked_offset; } @@ -283,7 +283,7 @@ Section::Dump(Stream *s, Process *process) const s->Printf(" + 0x%llx\n", m_linked_offset); } - m_children.Dump(s, process, false); + m_children.Dump(s, target, false); } void @@ -668,7 +668,7 @@ SectionList::ContainsSection(user_id_t sect_id) const } void -SectionList::Dump (Stream *s, Process *process, bool show_header) const +SectionList::Dump (Stream *s, Target *target, bool show_header) const { if (show_header && !m_sections.empty()) { @@ -678,7 +678,7 @@ SectionList::Dump (Stream *s, Process *process, bool show_header) const s->IndentMore(); s->Printf("%*s", 2*(sizeof(void *) + 2), ""); s->Indent(); - s->Printf("SectID %s Address File Off. File Size Flags Section Name\n", process ? "Load" : "File"); + s->Printf("SectID %s Address File Off. File Size Flags Section Name\n", (target && target->GetSectionLoadList().IsEmpty() == false) ? "Load" : "File"); s->Printf("%*s", 2*(sizeof(void *) + 2), ""); s->Indent(); s->PutCString("---------- --------------------------------------- ---------- ---------- ---------- ----------------------------\n"); @@ -689,7 +689,7 @@ SectionList::Dump (Stream *s, Process *process, bool show_header) const const_iterator end = m_sections.end(); for (sect_iter = m_sections.begin(); sect_iter != end; ++sect_iter) { - (*sect_iter)->Dump(s, process); + (*sect_iter)->Dump(s, target); } if (show_header && !m_sections.empty()) diff --git a/lldb/source/Core/Value.cpp b/lldb/source/Core/Value.cpp index 77b1d50e06d..6105080e27c 100644 --- a/lldb/source/Core/Value.cpp +++ b/lldb/source/Core/Value.cpp @@ -558,7 +558,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx, clang::ASTContext *ast_context if (objfile) { Address so_addr(file_addr, objfile->GetSectionList()); - address = so_addr.GetLoadAddress (exe_ctx->process); + address = so_addr.GetLoadAddress (exe_ctx->target); if (address != LLDB_INVALID_ADDRESS) { address_type = eAddressTypeLoad; diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index 83206912ba3..cd087f8b90d 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -10,6 +10,8 @@ #include "lldb/Core/ValueObject.h" // C Includes +#include <stdlib.h> + // C++ Includes // Other libraries and framework includes #include "llvm/Support/raw_ostream.h" @@ -27,8 +29,8 @@ #include "lldb/Target/ExecutionContext.h" #include "lldb/Target/Process.h" #include "lldb/Target/RegisterContext.h" +#include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" -#include <stdlib.h> using namespace lldb; using namespace lldb_private; @@ -495,10 +497,10 @@ ValueObject::GetSummaryAsCString (ExecutionContextScope *exe_scope) case eAddressTypeLoad: { Address so_addr; - Process *process = exe_scope->CalculateProcess(); - if (process != NULL) + Target *target = exe_scope->CalculateTarget(); + if (target && target->GetSectionLoadList().IsEmpty() == false) { - if (process->ResolveLoadAddress(func_ptr_address, so_addr)) + if (target->GetSectionLoadList().ResolveLoadAddress(func_ptr_address, so_addr)) { so_addr.Dump (&sstr, exe_scope, diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp index 9a432ab381c..86cc46d207b 100644 --- a/lldb/source/Core/ValueObjectVariable.cpp +++ b/lldb/source/Core/ValueObjectVariable.cpp @@ -110,7 +110,7 @@ ValueObjectVariable::UpdateValue (ExecutionContextScope *exe_scope) SymbolContext sc; variable->CalculateSymbolContext (&sc); if (sc.function) - loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.process); + loclist_base_load_addr = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.target); } Value old_value(m_value); if (expr.Evaluate (&exe_ctx, GetClangAST(), loclist_base_load_addr, NULL, m_value, &m_error)) @@ -156,7 +156,7 @@ ValueObjectVariable::UpdateValue (ExecutionContextScope *exe_scope) if (objfile) { Address so_addr(file_addr, objfile->GetSectionList()); - lldb::addr_t load_addr = so_addr.GetLoadAddress (exe_ctx.process); + lldb::addr_t load_addr = so_addr.GetLoadAddress (exe_ctx.target); if (load_addr != LLDB_INVALID_ADDRESS) { m_value.SetValueType(Value::eValueTypeLoadAddress); |