diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-26 19:36:28 +0000 | 
| commit | cfca06d7963fa0909f90483b42a6d7d194d01e08 (patch) | |
| tree | 209fb2a2d68f8f277793fc8df46c753d31bc853b /lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp | |
| parent | 706b4fc47bbc608932d3b491ae19a3b9cde9497b (diff) | |
Notes
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp')
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp | 50 | 
1 files changed, 18 insertions, 32 deletions
| diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index f660cc32b3f8d..305f1cbd2826a 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -1,4 +1,4 @@ -//===-- DWARFFormValue.cpp --------------------------------------*- C++ -*-===// +//===-- DWARFFormValue.cpp ------------------------------------------------===//  //  // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.  // See https://llvm.org/LICENSE.txt for license information. @@ -454,40 +454,26 @@ void DWARFFormValue::Dump(Stream &s) const {  }  const char *DWARFFormValue::AsCString() const { -  SymbolFileDWARF &symbol_file = m_unit->GetSymbolFileDWARF(); +  DWARFContext &context = m_unit->GetSymbolFileDWARF().GetDWARFContext(); -  if (m_form == DW_FORM_string) { +  if (m_form == DW_FORM_string)      return m_value.value.cstr; -  } else if (m_form == DW_FORM_strp) { -    return symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr( -        m_value.value.uval); -  } else if (m_form == DW_FORM_GNU_str_index) { -    uint32_t index_size = 4; -    lldb::offset_t offset = m_value.value.uval * index_size; -    dw_offset_t str_offset = -        symbol_file.GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64( -            &offset, index_size); -    return symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr( -        str_offset); -  } - -  if (m_form == DW_FORM_strx || m_form == DW_FORM_strx1 || -      m_form == DW_FORM_strx2 || m_form == DW_FORM_strx3 || -      m_form == DW_FORM_strx4) { - -    // The same code as above. -    uint32_t indexSize = 4; -    lldb::offset_t offset = -        m_unit->GetStrOffsetsBase() + m_value.value.uval * indexSize; -    dw_offset_t strOffset = -        symbol_file.GetDWARFContext().getOrLoadStrOffsetsData().GetMaxU64( -            &offset, indexSize); -    return symbol_file.GetDWARFContext().getOrLoadStrData().PeekCStr(strOffset); +  if (m_form == DW_FORM_strp) +    return context.getOrLoadStrData().PeekCStr(m_value.value.uval); + +  if (m_form == DW_FORM_GNU_str_index || m_form == DW_FORM_strx || +      m_form == DW_FORM_strx1 || m_form == DW_FORM_strx2 || +      m_form == DW_FORM_strx3 || m_form == DW_FORM_strx4) { + +    llvm::Optional<uint64_t> offset = +        m_unit->GetStringOffsetSectionItem(m_value.value.uval); +    if (!offset) +      return nullptr; +    return context.getOrLoadStrData().PeekCStr(*offset);    }    if (m_form == DW_FORM_line_strp) -    return symbol_file.GetDWARFContext().getOrLoadLineStrData().PeekCStr( -        m_value.value.uval); +    return context.getOrLoadLineStrData().PeekCStr(m_value.value.uval);    return nullptr;  } @@ -531,7 +517,7 @@ DWARFDIE DWARFFormValue::Reference() const {    case DW_FORM_ref_addr: {      DWARFUnit *ref_cu = -        m_unit->GetSymbolFileDWARF().DebugInfo()->GetUnitContainingDIEOffset( +        m_unit->GetSymbolFileDWARF().DebugInfo().GetUnitContainingDIEOffset(              DIERef::Section::DebugInfo, value);      if (!ref_cu) {        m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError( @@ -544,7 +530,7 @@ DWARFDIE DWARFFormValue::Reference() const {    case DW_FORM_ref_sig8: {      DWARFTypeUnit *tu = -        m_unit->GetSymbolFileDWARF().DebugInfo()->GetTypeUnitForHash(value); +        m_unit->GetSymbolFileDWARF().DebugInfo().GetTypeUnitForHash(value);      if (!tu)        return {};      return tu->GetDIE(tu->GetTypeOffset()); | 
