diff --git a/lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py b/lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py --- a/lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py @@ -26,11 +26,9 @@ # Find the line number to of function 'c'. self.line = line_number('main.c', '// Break at this line') - @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24772") - @add_test_categories(['pyapi']) - def test(self): + def run_test(self, dwarf_flag): """Exercise some SBValue APIs.""" - d = {'EXE': self.exe_name} + d = {'EXE': self.exe_name, 'DEBUG_INFO_FLAG': dwarf_flag} self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) exe = self.getBuildArtifact(self.exe_name) @@ -183,3 +181,15 @@ frame0.FindVariable('sinthex').GetValueAsSigned() == - 526164208, 'signed sinthex == -526164208') + + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24772") + @add_test_categories(['pyapi']) + def test_dw4(self): + self.run_test('-gdwarf-4') + + @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24772") + @add_test_categories(['pyapi']) + def test_dw5(self): + self.run_test('-gdwarf-5') + diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -514,6 +514,10 @@ s->Printf("DW_OP_GNU_addr_index(0x%" PRIx64 ")", m_data.GetULEB128(&offset)); break; + case DW_OP_addrx: + s->Printf("DW_OP_addrx(0x%" PRIx64 ")", + m_data.GetULEB128(&offset)); + break; case DW_OP_GNU_const_index: // 0xfc s->Printf("DW_OP_GNU_const_index(0x%" PRIx64 ")", m_data.GetULEB128(&offset)); @@ -877,6 +881,7 @@ return 8; // All opcodes that have a single ULEB (signed or unsigned) argument + case DW_OP_addrx: // 0xa1 1 ULEB128 index case DW_OP_constu: // 0x10 1 ULEB128 constant case DW_OP_consts: // 0x11 1 SLEB128 constant case DW_OP_plus_uconst: // 0x23 1 ULEB128 addend @@ -957,7 +962,7 @@ return op_file_addr; else ++curr_op_addr_idx; - } else if (op == DW_OP_GNU_addr_index) { + } else if (op == DW_OP_GNU_addr_index || op == DW_OP_addrx) { uint64_t index = m_data.GetULEB128(&offset); if (curr_op_addr_idx == op_addr_idx) { if (!m_dwarf_cu) { @@ -2902,13 +2907,14 @@ } break; //---------------------------------------------------------------------- - // OPCODE: DW_OP_GNU_addr_index + // OPCODE: DW_OP_addrx (DW_OP_GNU_addr_index is the legacy name.) // OPERANDS: 1 // ULEB128: index to the .debug_addr section // DESCRIPTION: Pushes an address to the stack from the .debug_addr // section with the base address specified by the DW_AT_addr_base attribute // and the 0 based index is the ULEB128 encoded index. //---------------------------------------------------------------------- + case DW_OP_addrx: case DW_OP_GNU_addr_index: { if (!dwarf_cu) { if (error_ptr) @@ -3194,6 +3200,7 @@ case DW_OP_call_ref: size = dwarf_ref_size; break; + case DW_OP_addrx: case DW_OP_piece: case DW_OP_plus_uconst: case DW_OP_regx: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -326,6 +326,7 @@ break; // signed or unsigned LEB 128 values + case DW_FORM_addrx: case DW_FORM_sdata: case DW_FORM_udata: case DW_FORM_ref_udata: @@ -456,6 +457,7 @@ case DW_AT_high_pc: if (form_value.Form() == DW_FORM_addr || + form_value.Form() == DW_FORM_addrx || form_value.Form() == DW_FORM_GNU_addr_index) { hi_pc = form_value.Address(); } else { @@ -1031,7 +1033,8 @@ if (GetAttributeValue(dwarf2Data, cu, DW_AT_high_pc, form_value, nullptr, check_specification_or_abstract_origin)) { dw_form_t form = form_value.Form(); - if (form == DW_FORM_addr || form == DW_FORM_GNU_addr_index) + if (form == DW_FORM_addr || form == DW_FORM_addrx || + form == DW_FORM_GNU_addr_index) return form_value.Address(); // DWARF4 can specify the hi_pc as an diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -681,6 +681,7 @@ return 1; switch (a_form) { case DW_FORM_addr: + case DW_FORM_addrx: case DW_FORM_flag: case DW_FORM_data1: case DW_FORM_data2: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp --- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp @@ -166,6 +166,7 @@ case DW_FORM_ref_sig8: llvm_unreachable("Unhandled atom form"); + case DW_FORM_addrx: case DW_FORM_string: case DW_FORM_block: case DW_FORM_block1: