diff options
Diffstat (limited to 'lldb/source')
9 files changed, 85 insertions, 32 deletions
| diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 4e4aa48..f58a1b5 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -239,11 +239,34 @@ SBThread::GetStopReasonExtendedBacktraces(InstrumentationRuntimeType type) {    return threads;  } -size_t SBThread::GetStopDescription(char *dst, size_t dst_len) { -  LLDB_INSTRUMENT_VA(this, dst, dst_len); +bool SBThread::GetStopDescription(lldb::SBStream &stream) const { +  LLDB_INSTRUMENT_VA(this, stream); + +  if (!m_opaque_sp) +    return false; + +  llvm::Expected<StoppedExecutionContext> exe_ctx = +      GetStoppedExecutionContext(m_opaque_sp); +  if (!exe_ctx) { +    LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}"); +    return false; +  } + +  if (!exe_ctx->HasThreadScope()) +    return false; + +  Stream &strm = stream.ref(); +  const std::string stop_desc = exe_ctx->GetThreadPtr()->GetStopDescription(); +  strm.PutCString(stop_desc); + +  return true; +} + +size_t SBThread::GetStopDescription(char *dst_or_null, size_t dst_len) { +  LLDB_INSTRUMENT_VA(this, dst_or_null, dst_len); -  if (dst) -    *dst = 0; +  if (dst_or_null) +    *dst_or_null = 0;    llvm::Expected<StoppedExecutionContext> exe_ctx =        GetStoppedExecutionContext(m_opaque_sp); @@ -259,8 +282,8 @@ size_t SBThread::GetStopDescription(char *dst, size_t dst_len) {    if (thread_stop_desc.empty())      return 0; -  if (dst) -    return ::snprintf(dst, dst_len, "%s", thread_stop_desc.c_str()) + 1; +  if (dst_or_null) +    return ::snprintf(dst_or_null, dst_len, "%s", thread_stop_desc.c_str()) + 1;    // NULL dst passed in, return the length needed to contain the    // description. diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 9cdb846..c8e520d 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -1674,6 +1674,10 @@ void ObjectFileMachO::ProcessSegmentCommand(    uint32_t segment_sect_idx;    const lldb::user_id_t first_segment_sectID = context.NextSectionIdx + 1; +  // 64 bit mach-o files have sections with 32 bit file offsets. If any section +  // data end will exceed UINT32_MAX, then we need to do some bookkeeping to +  // ensure we can access this data correctly. +  uint64_t section_offset_adjust = 0;    const uint32_t num_u32s = load_cmd.cmd == LC_SEGMENT ? 7 : 8;    for (segment_sect_idx = 0; segment_sect_idx < load_cmd.nsects;         ++segment_sect_idx) { @@ -1697,6 +1701,16 @@ void ObjectFileMachO::ProcessSegmentCommand(      // isn't stored in the abstracted Sections.      m_mach_sections.push_back(sect64); +    // Make sure we can load sections in mach-o files where some sections cross +    // a 4GB boundary. llvm::MachO::section_64 have only 32 bit file offsets +    // for the file offset of the section contents, so we need to track and +    // sections that overflow and adjust the offsets accordingly. +    const uint64_t section_file_offset = +        (uint64_t)sect64.offset + section_offset_adjust; +    const uint64_t end_section_offset = (uint64_t)sect64.offset + sect64.size; +    if (end_section_offset >= UINT32_MAX) +      section_offset_adjust += end_section_offset & 0xFFFFFFFF00000000ull; +      if (add_section) {        ConstString section_name(            sect64.sectname, strnlen(sect64.sectname, sizeof(sect64.sectname))); @@ -1736,13 +1750,13 @@ void ObjectFileMachO::ProcessSegmentCommand(            }            // Grow the section size as needed. -          if (sect64.offset) { +          if (section_file_offset) {              const lldb::addr_t segment_min_file_offset =                  segment->GetFileOffset();              const lldb::addr_t segment_max_file_offset =                  segment_min_file_offset + segment->GetFileSize(); -            const lldb::addr_t section_min_file_offset = sect64.offset; +            const lldb::addr_t section_min_file_offset = section_file_offset;              const lldb::addr_t section_max_file_offset =                  section_min_file_offset + sect64.size;              const lldb::addr_t new_file_offset = @@ -1769,10 +1783,10 @@ void ObjectFileMachO::ProcessSegmentCommand(                // other sections.                sect64.addr, // File VM address == addresses as they are                // found in the object file -              sect64.size,   // VM size in bytes of this section -              sect64.offset, // Offset to the data for this section in +              sect64.size,         // VM size in bytes of this section +              section_file_offset, // Offset to the data for this section in                // the file -              sect64.offset ? sect64.size : 0, // Size in bytes of +              section_file_offset ? sect64.size : 0, // Size in bytes of                // this section as                // found in the file                sect64.align, @@ -1792,14 +1806,14 @@ void ObjectFileMachO::ProcessSegmentCommand(        SectionSP section_sp(new Section(            segment_sp, module_sp, this, ++context.NextSectionIdx, section_name,            sect_type, sect64.addr - segment_sp->GetFileAddress(), sect64.size, -          sect64.offset, sect64.offset == 0 ? 0 : sect64.size, sect64.align, -          sect64.flags)); +          section_file_offset, section_file_offset == 0 ? 0 : sect64.size, +          sect64.align, sect64.flags));        // Set the section to be encrypted to match the segment        bool section_is_encrypted = false;        if (!segment_is_encrypted && load_cmd.filesize != 0)          section_is_encrypted = context.EncryptedRanges.FindEntryThatContains( -                                   sect64.offset) != nullptr; +                                   section_file_offset) != nullptr;        section_sp->SetIsEncrypted(segment_is_encrypted || section_is_encrypted);        section_sp->SetPermissions(segment_permissions); diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h index 7b39d29..27f5d2e 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/SWIGPythonBridge.h @@ -158,8 +158,9 @@ public:    static PyObject *LLDBSwigPython_GetChildAtIndex(PyObject *implementor,                                                    uint32_t idx); -  static int LLDBSwigPython_GetIndexOfChildWithName(PyObject *implementor, -                                                    const char *child_name); +  static uint32_t +  LLDBSwigPython_GetIndexOfChildWithName(PyObject *implementor, +                                         const char *child_name);    static lldb::ValueObjectSP    LLDBSWIGPython_GetValueObjectSPFromSBValue(void *data); diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp index 73c5c72..d257a08 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp @@ -1939,7 +1939,7 @@ lldb::ValueObjectSP ScriptInterpreterPythonImpl::GetChildAtIndex(    return ret_val;  } -llvm::Expected<int> ScriptInterpreterPythonImpl::GetIndexOfChildWithName( +llvm::Expected<uint32_t> ScriptInterpreterPythonImpl::GetIndexOfChildWithName(      const StructuredData::ObjectSP &implementor_sp, const char *child_name) {    if (!implementor_sp)      return llvm::createStringError("Type has no child named '%s'", child_name); @@ -1951,7 +1951,7 @@ llvm::Expected<int> ScriptInterpreterPythonImpl::GetIndexOfChildWithName(    if (!implementor)      return llvm::createStringError("Type has no child named '%s'", child_name); -  int ret_val = INT32_MAX; +  uint32_t ret_val = UINT32_MAX;    {      Locker py_lock(this, @@ -1960,7 +1960,7 @@ llvm::Expected<int> ScriptInterpreterPythonImpl::GetIndexOfChildWithName(                                                                   child_name);    } -  if (ret_val == INT32_MAX) +  if (ret_val == UINT32_MAX)      return llvm::createStringError("Type has no child named '%s'", child_name);    return ret_val;  } diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h index dedac28..00ae59c 100644 --- a/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h +++ b/lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPythonImpl.h @@ -122,7 +122,7 @@ public:    GetChildAtIndex(const StructuredData::ObjectSP &implementor,                    uint32_t idx) override; -  llvm::Expected<int> +  llvm::Expected<uint32_t>    GetIndexOfChildWithName(const StructuredData::ObjectSP &implementor,                            const char *child_name) override; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index 82e9d86..c049829 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -450,6 +450,10 @@ ParsedDWARFTypeAttributes::ParsedDWARFTypeAttributes(const DWARFDIE &die) {        byte_size = form_value.Unsigned();        break; +    case DW_AT_bit_size: +      data_bit_size = form_value.Unsigned(); +      break; +      case DW_AT_alignment:        alignment = form_value.Unsigned();        break; @@ -1901,6 +1905,17 @@ DWARFASTParserClang::ParseStructureLikeDIE(const SymbolContext &sc,          m_ast.CreateClassTemplateSpecializationDecl(              containing_decl_ctx, GetOwningClangModule(die), class_template_decl,              tag_decl_kind, template_param_infos); +    if (!class_specialization_decl) { +      if (log) { +        dwarf->GetObjectFile()->GetModule()->LogMessage( +            log, +            "SymbolFileDWARF({0:p}) - Failed to create specialization for " +            "clang::ClassTemplateDecl({1}, {2:p}).", +            this, llvm::StringRef(attrs.name), class_template_decl); +      } +      return TypeSP(); +    } +      clang_type =          m_ast.CreateClassTemplateSpecializationType(class_specialization_decl); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h index da58f4c..f5f7071 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -574,6 +574,7 @@ struct ParsedDWARFTypeAttributes {    lldb_private::plugin::dwarf::DWARFFormValue type;    lldb::LanguageType class_language = lldb::eLanguageTypeUnknown;    std::optional<uint64_t> byte_size; +  std::optional<uint64_t> data_bit_size;    std::optional<uint64_t> alignment;    size_t calling_convention = llvm::dwarf::DW_CC_normal;    uint32_t bit_stride = 0; diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index 3b936c0..0ccb1804 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -83,8 +83,8 @@ constexpr OptionEnumValueElement g_pdb_reader_enums[] = {      {          ePDBReaderDefault,          "default", -        "Use DIA PDB reader unless LLDB_USE_NATIVE_PDB_READER environment " -        "variable is set", +        "Use native PDB reader unless LLDB_USE_NATIVE_PDB_READER environment " +        "is set to 0",      },      {          ePDBReaderDIA, @@ -109,16 +109,10 @@ enum {  static const bool g_should_use_native_reader_by_default = [] {    llvm::StringRef env_value = ::getenv("LLDB_USE_NATIVE_PDB_READER"); -#if !LLVM_ENABLE_DIA_SDK || !defined(_WIN32) -  // if the environment value is unset, the native reader is requested -  if (env_value.empty()) -    return true; -#endif - -  return env_value.equals_insensitive("on") || -         env_value.equals_insensitive("yes") || -         env_value.equals_insensitive("1") || -         env_value.equals_insensitive("true"); +  return !env_value.equals_insensitive("off") && +         !env_value.equals_insensitive("no") && +         !env_value.equals_insensitive("0") && +         !env_value.equals_insensitive("false");  }();  class PluginProperties : public Properties { diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 82dfe7e..6ec054d 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -1693,6 +1693,11 @@ TypeSystemClang::CreateClassTemplateSpecializationDecl(    class_template_specialization_decl->setInstantiationOf(class_template_decl);    class_template_specialization_decl->setTemplateArgs(        TemplateArgumentList::CreateCopy(ast, args)); +  void *insert_pos = nullptr; +  if (class_template_decl->findSpecialization(args, insert_pos)) +    return nullptr; +  class_template_decl->AddSpecialization(class_template_specialization_decl, +                                         insert_pos);    class_template_specialization_decl->setDeclName(        class_template_decl->getDeclName()); | 
