Skip to content

Conversation

@JDevlieghere
Copy link
Member

@JDevlieghere JDevlieghere commented Dec 16, 2024

The improved error reporting in #120162 revealed that we were missing
opcodes in GetOpcodeDataSize. I changed the function to remove the
default case and switch over the enum type which will cause the compiler
to emit a warning if there are unhandled operations in the future.

rdar://139705570

@llvmbot
Copy link
Member

llvmbot commented Dec 17, 2024

@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)

Changes

The improved error reporting in #120162 revealed that we were missing opcodes in GetOpcodeDataSize.

rdar://139705570


Full diff: https://github.com/llvm/llvm-project/pull/120163.diff

1 Files Affected:

  • (modified) lldb/source/Expression/DWARFExpression.cpp (+3)
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index a7126b25c1cc38..34d508f97ae012 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -269,6 +269,7 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
 
   // All opcodes that have a single ULEB (signed or unsigned) argument
   case DW_OP_addrx:           // 0xa1 1 ULEB128 index
+  case DW_OP_constx:          // 0xa2 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
@@ -307,6 +308,8 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
   case DW_OP_regx:            // 0x90 1 ULEB128 register
   case DW_OP_fbreg:           // 0x91 1 SLEB128 offset
   case DW_OP_piece:           // 0x93 1 ULEB128 size of piece addressed
+  case DW_OP_convert:         // 0xa8 1 ULEB128 offset
+  case DW_OP_reinterpret:     // 0xa9 1 ULEB128 offset
   case DW_OP_GNU_addr_index:  // 0xfb 1 ULEB128 index
   case DW_OP_GNU_const_index: // 0xfc 1 ULEB128 index
     data.Skip_LEB128(&offset);


// All opcodes that have a single ULEB (signed or unsigned) argument
case DW_OP_addrx: // 0xa1 1 ULEB128 index
case DW_OP_constx: // 0xa2 1 ULEB128 index
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there might be value in keeping the list sorted by their numeric value.

case DW_OP_reinterpret: // 0xa9 1 ULEB128 offset
case DW_OP_GNU_addr_index: // 0xfb 1 ULEB128 index
case DW_OP_GNU_const_index: // 0xfc 1 ULEB128 index
data.Skip_LEB128(&offset);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we list all values explicitly and get rid of the default so we get a warning about missing entries in the future?

The improved error reporting in llvm#120162 revealed that we were missing
opcodes in GetOpcodeDataSize. I changed the function to remove the
default case and switch over the enum type which will cause the compiler
to emit a warning if there are unhandled operations in the future.

rdar://139705570
Copy link
Collaborator

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found one bug, otherwise this looks good!

case DW_OP_implicit_pointer: // 0xa0 4 + LEB128
{
data.Skip_LEB128(&offset);
return 4 + offset - data_offset;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first operand is a 4-byte unsigned value in the 32-bit DWARF format, or an 8-byte unsigned value in the 64-bit DWARF format

@JDevlieghere JDevlieghere merged commit 4cf1fe2 into llvm:main Jan 23, 2025
5 of 6 checks passed
@JDevlieghere JDevlieghere deleted the rdar139705570-part-2 branch January 23, 2025 18:37
JDevlieghere added a commit to swiftlang/llvm-project that referenced this pull request Jan 23, 2025
The improved error reporting in llvm#120162 revealed that we were missing
opcodes in GetOpcodeDataSize. I changed the function to remove the
default case and switch over the enum type which will cause the compiler
to emit a warning if there are unhandled operations in the future.

rdar://139705570
(cherry picked from commit 4cf1fe2)
adrian-prantl added a commit to swiftlang/llvm-project that referenced this pull request Jan 23, 2025
…4cf1fe240589

[🍒 swift/release/6.1] [lldb] Add missing operations to GetOpcodeDataSize (llvm#120163)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants