diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index 94b36e8b18bd..3bcadbe9ed4a 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -2535,9 +2535,10 @@ bool DWARFExpression::Evaluate( } default: - LLDB_LOGF(log, "Unhandled opcode %s in DWARFExpression.", - DW_OP_value_to_name(op)); - break; + if (error_ptr) + error_ptr->SetErrorStringWithFormatv( + "Unhandled opcode {0} in DWARFExpression", LocationAtom(op)); + return false; } } diff --git a/lldb/test/Shell/SymbolFile/DWARF/DW_TAG_variable-invalid_location.s b/lldb/test/Shell/SymbolFile/DWARF/DW_TAG_variable-invalid_location.s new file mode 100644 index 000000000000..2295c52f5ead --- /dev/null +++ b/lldb/test/Shell/SymbolFile/DWARF/DW_TAG_variable-invalid_location.s @@ -0,0 +1,61 @@ +# RUN: llvm-mc -filetype=obj -o %t -triple x86_64-pc-linux %s +# RUN: %lldb %t -o "target variable var" -b | FileCheck %s + +# CHECK: (lldb) target variable var +# CHECK: (long) var = + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 8 # DW_FORM_string + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 8 # DW_FORM_string + .byte 62 # DW_AT_encoding + .byte 11 # DW_FORM_data1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Lcu_end-.Lcu_start # Length of Unit +.Lcu_start: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x6c DW_TAG_compile_unit +.Llong: + .byte 3 # Abbrev [3] 0x33:0x7 DW_TAG_base_type + .asciz "long" # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 8 # DW_AT_byte_size + .byte 2 # Abbrev [2] 0x3a:0x15 DW_TAG_variable + .asciz "var" # DW_AT_name + .long .Llong # DW_AT_type + .byte 2f-1f # DW_AT_location +1: + .byte 0xff # Invalid opcode + .byte 0xe # DW_OP_constu + .quad 0xdeadbeefbaadf00d + .byte 0x9f # DW_OP_stack_value +2: + .byte 0 # End Of Children Mark +.Lcu_end: diff --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp b/lldb/unittests/Expression/DWARFExpressionTest.cpp index 4c4281983078..590ac2fa8338 100644 --- a/lldb/unittests/Expression/DWARFExpressionTest.cpp +++ b/lldb/unittests/Expression/DWARFExpressionTest.cpp @@ -204,14 +204,14 @@ TEST(DWARFExpression, DW_OP_convert) { llvm::HasValue(GetScalar(64, 0xffffffffffeeddcc, is_signed))); // Truncate to 8 bits. - EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', 0xee, 0xff, // - DW_OP_convert, offs_uchar}), - llvm::HasValue(GetScalar(8, 'A', not_signed))); + EXPECT_THAT_EXPECTED( + t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', DW_OP_convert, offs_uchar}), + llvm::HasValue(GetScalar(8, 'A', not_signed))); // Also truncate to 8 bits. - EXPECT_THAT_EXPECTED(t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', 0xee, 0xff, // - DW_OP_convert, offs_schar}), - llvm::HasValue(GetScalar(8, 'A', is_signed))); + EXPECT_THAT_EXPECTED( + t.Eval({DW_OP_const4s, 'A', 'B', 'C', 'D', DW_OP_convert, offs_schar}), + llvm::HasValue(GetScalar(8, 'A', is_signed))); // // Errors. @@ -248,3 +248,10 @@ TEST(DWARFExpression, DW_OP_piece) { // represent that yet. llvm::HasValue(GetScalar(16, 0xff00, true))); } + +TEST(DWARFExpression, DW_OP_unknown) { + EXPECT_THAT_EXPECTED( + Evaluate({0xff}), + llvm::FailedWithMessage( + "Unhandled opcode DW_OP_unknown_ff in DWARFExpression")); +}