-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] Add missing operations to GetOpcodeDataSize #120163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,10 +132,35 @@ static llvm::Error ReadRegisterValueAsScalar(RegisterContext *reg_ctx, | |
/// are made on the state of \p data after this call. | ||
static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, | ||
const lldb::offset_t data_offset, | ||
const uint8_t op, | ||
const LocationAtom op, | ||
const DWARFUnit *dwarf_cu) { | ||
lldb::offset_t offset = data_offset; | ||
switch (op) { | ||
// Only used in LLVM metadata. | ||
case DW_OP_LLVM_fragment: | ||
case DW_OP_LLVM_convert: | ||
case DW_OP_LLVM_tag_offset: | ||
case DW_OP_LLVM_entry_value: | ||
case DW_OP_LLVM_implicit_pointer: | ||
case DW_OP_LLVM_arg: | ||
case DW_OP_LLVM_extract_bits_sext: | ||
case DW_OP_LLVM_extract_bits_zext: | ||
break; | ||
// Vendor extensions: | ||
case DW_OP_HP_is_value: | ||
case DW_OP_HP_fltconst4: | ||
case DW_OP_HP_fltconst8: | ||
case DW_OP_HP_mod_range: | ||
case DW_OP_HP_unmod_range: | ||
case DW_OP_HP_tls: | ||
case DW_OP_INTEL_bit_piece: | ||
case DW_OP_WASM_location: | ||
case DW_OP_WASM_location_int: | ||
case DW_OP_APPLE_uninit: | ||
case DW_OP_PGI_omp_thread_num: | ||
case DW_OP_hi_user: | ||
break; | ||
|
||
case DW_OP_addr: | ||
case DW_OP_call_ref: // 0x9a 1 address sized offset of DIE (DWARF3) | ||
return data.GetAddressByteSize(); | ||
|
@@ -246,6 +271,7 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, | |
case DW_OP_pick: // 0x15 1 1-byte stack index | ||
case DW_OP_deref_size: // 0x94 1 1-byte size of data retrieved | ||
case DW_OP_xderef_size: // 0x95 1 1-byte size of data retrieved | ||
case DW_OP_deref_type: // 0xa6 1 1-byte constant | ||
return 1; | ||
|
||
// Opcodes with a single 2 byte arguments | ||
|
@@ -268,7 +294,6 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, | |
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 | ||
|
@@ -307,14 +332,20 @@ 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_addrx: // 0xa1 1 ULEB128 index | ||
case DW_OP_constx: // 0xa2 1 ULEB128 index | ||
case DW_OP_xderef_type: // 0xa7 1 ULEB128 index | ||
case DW_OP_GNU_addr_index: // 0xfb 1 ULEB128 index | ||
case DW_OP_GNU_const_index: // 0xfc 1 ULEB128 index | ||
data.Skip_LEB128(&offset); | ||
return offset - data_offset; | ||
|
||
// All opcodes that have a 2 ULEB (signed or unsigned) arguments | ||
case DW_OP_bregx: // 0x92 2 ULEB128 register followed by SLEB128 offset | ||
case DW_OP_bit_piece: // 0x9d ULEB128 bit size, ULEB128 bit offset (DWARF3); | ||
case DW_OP_bregx: // 0x92 2 ULEB128 register followed by SLEB128 offset | ||
case DW_OP_bit_piece: // 0x9d ULEB128 bit size, ULEB128 bit offset (DWARF3); | ||
case DW_OP_regval_type: // 0xa5 ULEB128 + ULEB128 | ||
data.Skip_LEB128(&offset); | ||
data.Skip_LEB128(&offset); | ||
return offset - data_offset; | ||
|
@@ -327,27 +358,45 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data, | |
return offset - data_offset; | ||
} | ||
|
||
case DW_OP_implicit_pointer: // 0xa0 4 + LEB128 | ||
{ | ||
data.Skip_LEB128(&offset); | ||
return 4 + offset - data_offset; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
case DW_OP_GNU_entry_value: | ||
case DW_OP_entry_value: // 0xa3 ULEB128 size + variable-length block | ||
{ | ||
uint64_t subexpr_len = data.GetULEB128(&offset); | ||
return (offset - data_offset) + subexpr_len; | ||
} | ||
|
||
default: | ||
if (!dwarf_cu) { | ||
return LLDB_INVALID_OFFSET; | ||
} | ||
case DW_OP_const_type: // 0xa4 ULEB128 + size + variable-length block | ||
{ | ||
data.Skip_LEB128(&offset); | ||
uint8_t length = data.GetU8(&offset); | ||
return (offset - data_offset) + length; | ||
} | ||
|
||
case DW_OP_LLVM_user: // 0xe9: ULEB128 + variable length constant | ||
{ | ||
uint64_t constants = data.GetULEB128(&offset); | ||
return (offset - data_offset) + constants; | ||
} | ||
} | ||
|
||
if (dwarf_cu) | ||
return dwarf_cu->GetSymbolFileDWARF().GetVendorDWARFOpcodeSize( | ||
data, data_offset, op); | ||
} | ||
|
||
return LLDB_INVALID_OFFSET; | ||
} | ||
|
||
llvm::Expected<lldb::addr_t> | ||
DWARFExpression::GetLocation_DW_OP_addr(const DWARFUnit *dwarf_cu) const { | ||
lldb::offset_t offset = 0; | ||
while (m_data.ValidOffset(offset)) { | ||
const uint8_t op = m_data.GetU8(&offset); | ||
const LocationAtom op = static_cast<LocationAtom>(m_data.GetU8(&offset)); | ||
|
||
if (op == DW_OP_addr) | ||
return m_data.GetAddress(&offset); | ||
|
@@ -376,7 +425,7 @@ bool DWARFExpression::Update_DW_OP_addr(const DWARFUnit *dwarf_cu, | |
lldb::addr_t file_addr) { | ||
lldb::offset_t offset = 0; | ||
while (m_data.ValidOffset(offset)) { | ||
const uint8_t op = m_data.GetU8(&offset); | ||
const LocationAtom op = static_cast<LocationAtom>(m_data.GetU8(&offset)); | ||
|
||
if (op == DW_OP_addr) { | ||
const uint32_t addr_byte_size = m_data.GetAddressByteSize(); | ||
|
@@ -434,7 +483,7 @@ bool DWARFExpression::ContainsThreadLocalStorage( | |
const DWARFUnit *dwarf_cu) const { | ||
lldb::offset_t offset = 0; | ||
while (m_data.ValidOffset(offset)) { | ||
const uint8_t op = m_data.GetU8(&offset); | ||
const LocationAtom op = static_cast<LocationAtom>(m_data.GetU8(&offset)); | ||
|
||
if (op == DW_OP_form_tls_address || op == DW_OP_GNU_push_tls_address) | ||
return true; | ||
|
@@ -465,7 +514,7 @@ bool DWARFExpression::LinkThreadLocalStorage( | |
lldb::addr_t const_value = 0; | ||
size_t const_byte_size = 0; | ||
while (m_data.ValidOffset(offset)) { | ||
const uint8_t op = m_data.GetU8(&offset); | ||
const LocationAtom op = static_cast<LocationAtom>(m_data.GetU8(&offset)); | ||
|
||
bool decoded_data = false; | ||
switch (op) { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?