diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-02-13 15:01:33 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-02-13 15:01:33 +0000 |
commit | 2fc5d2d1dfaf623ce4e24cd8590565902f8c557c (patch) | |
tree | 525149683974afa86747b749d45f0425749e972e /source | |
parent | e195173fdf080138dbb42936dea88c605e4b9a56 (diff) |
Vendor import of lldb release_38 branch r260756:vendor/lldb/lldb-release_380-r262564vendor/lldb/lldb-release_38-r260756
Notes
Notes:
svn path=/vendor/lldb/dist/; revision=295598
svn path=/vendor/lldb/lldb-release_380-r262564/; revision=296366; tag=vendor/lldb/lldb-release_380-r262564
Diffstat (limited to 'source')
-rw-r--r-- | source/API/SBInstruction.cpp | 8 | ||||
-rw-r--r-- | source/Core/Module.cpp | 13 | ||||
-rw-r--r-- | source/Expression/IRDynamicChecks.cpp | 4 | ||||
-rw-r--r-- | source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp | 15 | ||||
-rw-r--r-- | source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp | 15 | ||||
-rw-r--r-- | source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp | 21 | ||||
-rw-r--r-- | source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h | 7 | ||||
-rw-r--r-- | source/Plugins/Platform/MacOSX/Makefile | 19 | ||||
-rw-r--r-- | source/Symbol/GoASTContext.cpp | 151 | ||||
-rw-r--r-- | source/Symbol/Symtab.cpp | 20 | ||||
-rw-r--r-- | source/Target/Target.cpp | 18 |
11 files changed, 263 insertions, 28 deletions
diff --git a/source/API/SBInstruction.cpp b/source/API/SBInstruction.cpp index 36be94801863..a17f3f8dbd5d 100644 --- a/source/API/SBInstruction.cpp +++ b/source/API/SBInstruction.cpp @@ -160,6 +160,14 @@ SBInstruction::DoesBranch () return false; } +bool +SBInstruction::HasDelaySlot () +{ + if (m_opaque_sp) + return m_opaque_sp->HasDelaySlot (); + return false; +} + void SBInstruction::SetOpaque (const lldb::InstructionSP &inst_sp) { diff --git a/source/Core/Module.cpp b/source/Core/Module.cpp index 833540e1a309..a29456f5b5a5 100644 --- a/source/Core/Module.cpp +++ b/source/Core/Module.cpp @@ -559,7 +559,18 @@ Module::ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve Symtab *symtab = sym_vendor->GetSymtab(); if (symtab && so_addr.IsSectionOffset()) { - sc.symbol = symtab->FindSymbolContainingFileAddress(so_addr.GetFileAddress()); + Symbol *matching_symbol = nullptr; + + symtab->ForEachSymbolContainingFileAddress(so_addr.GetFileAddress(), + [&matching_symbol](Symbol *symbol) -> bool { + if (symbol->GetType() != eSymbolTypeInvalid) + { + matching_symbol = symbol; + return false; // Stop iterating + } + return true; // Keep iterating + }); + sc.symbol = matching_symbol; if (!sc.symbol && resolve_scope & eSymbolContextFunction && !(resolved_flags & eSymbolContextFunction)) { diff --git a/source/Expression/IRDynamicChecks.cpp b/source/Expression/IRDynamicChecks.cpp index 30d7f6330f65..64fdb08157aa 100644 --- a/source/Expression/IRDynamicChecks.cpp +++ b/source/Expression/IRDynamicChecks.cpp @@ -35,12 +35,12 @@ using namespace lldb_private; static char ID; -#define VALID_POINTER_CHECK_NAME "$__lldb_valid_pointer_check" +#define VALID_POINTER_CHECK_NAME "_$__lldb_valid_pointer_check" #define VALID_OBJC_OBJECT_CHECK_NAME "$__lldb_objc_object_check" static const char g_valid_pointer_check_text[] = "extern \"C\" void\n" -"$__lldb_valid_pointer_check (unsigned char *$__lldb_arg_ptr)\n" +"_$__lldb_valid_pointer_check (unsigned char *$__lldb_arg_ptr)\n" "{\n" " unsigned char $__lldb_local_val = *$__lldb_arg_ptr;\n" "}"; diff --git a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp index 3c7e9495d6ce..1b77946c1d1f 100644 --- a/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp +++ b/source/Plugins/ABI/SysV-mips/ABISysV_mips.cpp @@ -242,16 +242,27 @@ ABISysV_mips::PrepareTrivialCall (Thread &thread, const RegisterInfo *sp_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); const RegisterInfo *ra_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); const RegisterInfo *r25_info = reg_ctx->GetRegisterInfoByName("r25", 0); + const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("zero", 0); if (log) - log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); + log->Printf("Writing R0: 0x%" PRIx64, (uint64_t)0); + + /* Write r0 with 0, in case we are stopped in syscall, + * such setting prevents automatic decrement of the PC. + * This clears the bug 23659 for MIPS. + */ + if (!reg_ctx->WriteRegisterFromUnsigned (r0_info, (uint64_t)0)) + return false; + + if (log) + log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); // Set "sp" to the requested value if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_info, sp)) return false; if (log) - log->Printf("Writing RA: 0x%" PRIx64, (uint64_t)return_addr); + log->Printf("Writing RA: 0x%" PRIx64, (uint64_t)return_addr); // Set "ra" to the return address if (!reg_ctx->WriteRegisterFromUnsigned (ra_reg_info, return_addr)) diff --git a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp index e3da3631723e..8226ef15f494 100644 --- a/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp +++ b/source/Plugins/ABI/SysV-mips64/ABISysV_mips64.cpp @@ -207,16 +207,27 @@ ABISysV_mips64::PrepareTrivialCall (Thread &thread, const RegisterInfo *sp_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_SP); const RegisterInfo *ra_reg_info = reg_ctx->GetRegisterInfo (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_RA); const RegisterInfo *r25_info = reg_ctx->GetRegisterInfoByName("r25", 0); + const RegisterInfo *r0_info = reg_ctx->GetRegisterInfoByName("zero", 0); if (log) - log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); + log->Printf("Writing R0: 0x%" PRIx64, (uint64_t)0); + + /* Write r0 with 0, in case we are stopped in syscall, + * such setting prevents automatic decrement of the PC. + * This clears the bug 23659 for MIPS. + */ + if (!reg_ctx->WriteRegisterFromUnsigned (r0_info, (uint64_t)0)) + return false; + + if (log) + log->Printf("Writing SP: 0x%" PRIx64, (uint64_t)sp); // Set "sp" to the requested value if (!reg_ctx->WriteRegisterFromUnsigned (sp_reg_info, sp)) return false; if (log) - log->Printf("Writing RA: 0x%" PRIx64, (uint64_t)return_addr); + log->Printf("Writing RA: 0x%" PRIx64, (uint64_t)return_addr); // Set "ra" to the return address if (!reg_ctx->WriteRegisterFromUnsigned (ra_reg_info, return_addr)) diff --git a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp index b66244813240..ccd4400995c7 100644 --- a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -169,6 +169,18 @@ ObjectFilePECOFF::MagicBytesMatch (DataBufferSP& data_sp) return magic == IMAGE_DOS_SIGNATURE; } +lldb::SymbolType +ObjectFilePECOFF::MapSymbolType(uint16_t coff_symbol_type) +{ + // TODO: We need to complete this mapping of COFF symbol types to LLDB ones. + // For now, here's a hack to make sure our function have types. + const auto complex_type = coff_symbol_type >> llvm::COFF::SCT_COMPLEX_TYPE_SHIFT; + if (complex_type == llvm::COFF::IMAGE_SYM_DTYPE_FUNCTION) + { + return lldb::eSymbolTypeCode; + } + return lldb::eSymbolTypeInvalid; +} ObjectFilePECOFF::ObjectFilePECOFF (const lldb::ModuleSP &module_sp, DataBufferSP& data_sp, @@ -534,8 +546,8 @@ ObjectFilePECOFF::GetSymtab() { const uint32_t symbol_size = 18; const uint32_t addr_byte_size = GetAddressByteSize (); - const size_t symbol_data_size = num_syms * symbol_size; - // Include the 4 bytes string table size at the end of the symbols + const size_t symbol_data_size = num_syms * symbol_size; + // Include the 4-byte string table size at the end of the symbols DataBufferSP symtab_data_sp(m_file.ReadFileContents (m_coff_header.symoff, symbol_data_size + 4)); DataExtractor symtab_data (symtab_data_sp, GetByteOrder(), addr_byte_size); lldb::offset_t offset = symbol_data_size; @@ -556,8 +568,8 @@ ObjectFilePECOFF::GetSymtab() coff_symbol_t symbol; const uint32_t symbol_offset = offset; const char *symbol_name_cstr = NULL; - // If the first 4 bytes of the symbol string are zero, then we - // it is followed by a 4 byte string table offset. Else these + // If the first 4 bytes of the symbol string are zero, then they + // are followed by a 4-byte string table offset. Else these // 8 bytes contain the symbol name if (symtab_data.GetU32 (&offset) == 0) { @@ -586,6 +598,7 @@ ObjectFilePECOFF::GetSymtab() { Address symbol_addr(sect_list->GetSectionAtIndex(symbol.sect-1), symbol.value); symbols[i].GetAddressRef() = symbol_addr; + symbols[i].SetType(MapSymbolType(symbol.type)); } if (symbol.naux > 0) diff --git a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h index fd33cd3d32f8..44e5ee1b044b 100644 --- a/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h +++ b/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h @@ -101,7 +101,10 @@ public: static bool MagicBytesMatch (lldb::DataBufferSP& data_sp); - + + static lldb::SymbolType + MapSymbolType(uint16_t coff_symbol_type); + bool ParseHeader() override; @@ -116,7 +119,7 @@ public: uint32_t GetAddressByteSize() const override; - + // virtual lldb_private::AddressClass // GetAddressClass (lldb::addr_t file_addr); diff --git a/source/Plugins/Platform/MacOSX/Makefile b/source/Plugins/Platform/MacOSX/Makefile index 3e61dc982bd6..4377d369bc19 100644 --- a/source/Plugins/Platform/MacOSX/Makefile +++ b/source/Plugins/Platform/MacOSX/Makefile @@ -8,6 +8,25 @@ ##===----------------------------------------------------------------------===## LLDB_LEVEL := ../../../.. +LEVEL := $(LLDB_LEVEL)/../.. + +include $(LEVEL)/Makefile.config + +SOURCES += PlatformDarwin.cpp \ + PlatformDarwinKernel.cpp \ + PlatformMacOSX.cpp \ + PlatformRemoteiOS.cpp \ + PlatformRemoteAppleTV.cpp \ + PlatformRemoteAppleWatch.cpp + +ifeq ($(HOST_OS),Darwin) +SOURCES += PlatformAppleSimulator.cpp \ + PlatformiOSSimulator.cpp \ + PlatformiOSSimulatorCoreSimulatorSupport.mm \ + PlatformAppleTVSimulator.cpp \ + PlatformAppleWatchSimulator.cpp +endif + LIBRARYNAME := lldbPluginPlatformMacOSX BUILD_ARCHIVE = 1 diff --git a/source/Symbol/GoASTContext.cpp b/source/Symbol/GoASTContext.cpp index 4ba51f7580d7..1993f2331058 100644 --- a/source/Symbol/GoASTContext.cpp +++ b/source/Symbol/GoASTContext.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/StreamFile.h" #include "lldb/Core/UniqueCStringMap.h" #include "lldb/Core/ValueObject.h" #include "lldb/DataFormatters/StringPrinter.h" @@ -1268,13 +1269,115 @@ GoASTContext::ConvertStringToFloatValue(lldb::opaque_compiler_type_t type, const //---------------------------------------------------------------------- // Dumping types //---------------------------------------------------------------------- +#define DEPTH_INCREMENT 2 + void GoASTContext::DumpValue(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, lldb::Format format, - const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size, + const DataExtractor &data, lldb::offset_t data_byte_offset, size_t data_byte_size, uint32_t bitfield_bit_size, uint32_t bitfield_bit_offset, bool show_types, bool show_summary, bool verbose, uint32_t depth) { - assert(false); + if (IsTypedefType(type)) + type = GetTypedefedType(type).GetOpaqueQualType(); + if (!type) + return; + GoType *t = static_cast<GoType *>(type); + + if (GoStruct *st = t->GetStruct()) + { + if (GetCompleteType(type)) + { + uint32_t field_idx = 0; + for (auto* field = st->GetField(field_idx); field != nullptr; field_idx++) + { + // Print the starting squiggly bracket (if this is the + // first member) or comma (for member 2 and beyond) for + // the struct/union/class member. + if (field_idx == 0) + s->PutChar('{'); + else + s->PutChar(','); + + // Indent + s->Printf("\n%*s", depth + DEPTH_INCREMENT, ""); + + // Print the member type if requested + if (show_types) + { + ConstString field_type_name = field->m_type.GetTypeName(); + s->Printf("(%s) ", field_type_name.AsCString()); + } + // Print the member name and equal sign + s->Printf("%s = ", field->m_name.AsCString()); + + + // Dump the value of the member + CompilerType field_type = field->m_type; + field_type.DumpValue (exe_ctx, + s, // Stream to dump to + field_type.GetFormat(), // The format with which to display the member + data, // Data buffer containing all bytes for this type + data_byte_offset + field->m_byte_offset,// Offset into "data" where to grab value from + field->m_type.GetByteSize(exe_ctx->GetBestExecutionContextScope()), // Size of this type in bytes + 0, // Bitfield bit size + 0, // Bitfield bit offset + show_types, // Boolean indicating if we should show the variable types + show_summary, // Boolean indicating if we should show a summary for the current type + verbose, // Verbose output? + depth + DEPTH_INCREMENT); // Scope depth for any types that have children + } + + // Indent the trailing squiggly bracket + if (field_idx > 0) + s->Printf("\n%*s}", depth, ""); + + } + } + + if (GoArray *a = t->GetArray()) { + CompilerType element_clang_type = a->GetElementType(); + lldb::Format element_format = element_clang_type.GetFormat(); + uint32_t element_byte_size = element_clang_type.GetByteSize(exe_ctx->GetBestExecutionContextScope()); + + uint64_t element_idx; + for (element_idx = 0; element_idx < a->GetLength(); ++element_idx) + { + // Print the starting squiggly bracket (if this is the + // first member) or comman (for member 2 and beyong) for + // the struct/union/class member. + if (element_idx == 0) + s->PutChar('{'); + else + s->PutChar(','); + + // Indent and print the index + s->Printf("\n%*s[%" PRIu64 "] ", depth + DEPTH_INCREMENT, "", element_idx); + + // Figure out the field offset within the current struct/union/class type + uint64_t element_offset = element_idx * element_byte_size; + + // Dump the value of the member + element_clang_type.DumpValue (exe_ctx, + s, // Stream to dump to + element_format, // The format with which to display the element + data, // Data buffer containing all bytes for this type + data_byte_offset + element_offset,// Offset into "data" where to grab value from + element_byte_size, // Size of this type in bytes + 0, // Bitfield bit size + 0, // Bitfield bit offset + show_types, // Boolean indicating if we should show the variable types + show_summary, // Boolean indicating if we should show a summary for the current type + verbose, // Verbose output? + depth + DEPTH_INCREMENT); // Scope depth for any types that have children + } + + // Indent the trailing squiggly bracket + if (element_idx > 0) + s->Printf("\n%*s}", depth, ""); + } + + if (show_summary) + DumpSummary (type, exe_ctx, s, data, data_byte_offset, data_byte_size); } bool @@ -1371,19 +1474,55 @@ void GoASTContext::DumpSummary(lldb::opaque_compiler_type_t type, ExecutionContext *exe_ctx, Stream *s, const DataExtractor &data, lldb::offset_t data_offset, size_t data_byte_size) { - assert(false); + if (type && GoType::KIND_STRING == static_cast<GoType *>(type)->GetGoKind()) + { + // TODO(ribrdb): read length and data + } } void GoASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type) { - assert(false); -} // Dump to stdout + // Dump to stdout + StreamFile s (stdout, false); + DumpTypeDescription (type, &s); +} void GoASTContext::DumpTypeDescription(lldb::opaque_compiler_type_t type, Stream *s) { - assert(false); + if (!type) + return; + ConstString name = GetTypeName(type); + GoType *t = static_cast<GoType *>(type); + + if (GoStruct *st = t->GetStruct()) + { + if (GetCompleteType(type)) + { + if (NULL == strchr(name.AsCString(), '{')) + s->Printf("type %s ", name.AsCString()); + s->PutCString("struct {"); + if (st->GetNumFields() == 0) { + s->PutChar('}'); + return; + } + s->IndentMore(); + uint32_t field_idx = 0; + for (auto* field = st->GetField(field_idx); field != nullptr; field_idx++) + { + s->PutChar('\n'); + s->Indent(); + s->Printf("%s %s", field->m_name.AsCString(), field->m_type.GetTypeName().AsCString()); + } + s->IndentLess(); + s->PutChar('\n'); + s->Indent("}"); + return; + } + } + + s->PutCString(name.AsCString()); } CompilerType diff --git a/source/Symbol/Symtab.cpp b/source/Symbol/Symtab.cpp index b20504addec9..709d899075a4 100644 --- a/source/Symbol/Symtab.cpp +++ b/source/Symbol/Symtab.cpp @@ -1071,6 +1071,26 @@ Symtab::FindSymbolContainingFileAddress (addr_t file_addr) } void +Symtab::ForEachSymbolContainingFileAddress(addr_t file_addr, std::function<bool(Symbol *)> const &callback) +{ + Mutex::Locker locker (m_mutex); + + if (!m_file_addr_to_index_computed) + InitAddressIndexes(); + + std::vector<uint32_t> all_addr_indexes; + + // Get all symbols with file_addr + const size_t addr_match_count = m_file_addr_to_index.FindEntryIndexesThatContain(file_addr, all_addr_indexes); + + for (size_t i = 0; i < addr_match_count; ++i) + { + if (!callback(SymbolAtIndex(all_addr_indexes[i]))) + break; + } +} + +void Symtab::SymbolIndicesToSymbolContextList (std::vector<uint32_t> &symbol_indexes, SymbolContextList &sc_list) { // No need to protect this call using m_mutex all other method calls are diff --git a/source/Target/Target.cpp b/source/Target/Target.cpp index d2aa1bac49f6..21e42916bae9 100644 --- a/source/Target/Target.cpp +++ b/source/Target/Target.cpp @@ -2442,18 +2442,18 @@ Target::GetBreakableLoadAddress (lldb::addr_t addr) SymbolContext sc; uint32_t resolve_scope = eSymbolContextFunction | eSymbolContextSymbol; temp_addr_module_sp->ResolveSymbolContextForAddress(resolved_addr, resolve_scope, sc); + Address sym_addr; if (sc.function) - { - function_start = sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress(this); - if (function_start == LLDB_INVALID_ADDRESS) - function_start = sc.function->GetAddressRange().GetBaseAddress().GetFileAddress(); - } + sym_addr = sc.function->GetAddressRange().GetBaseAddress(); else if (sc.symbol) - { - Address sym_addr = sc.symbol->GetAddress(); + sym_addr = sc.symbol->GetAddress(); + + function_start = sym_addr.GetLoadAddress(this); + if (function_start == LLDB_INVALID_ADDRESS) function_start = sym_addr.GetFileAddress(); - } - current_offset = addr - function_start; + + if (function_start) + current_offset = addr - function_start; } // If breakpoint address is start of function then we dont have to do anything. |