@@ -136,10 +136,35 @@ static llvm::Error ReadRegisterValueAsScalar(RegisterContext *reg_ctx,
136136// / are made on the state of \p data after this call.
137137static lldb::offset_t GetOpcodeDataSize (const DataExtractor &data,
138138 const lldb::offset_t data_offset,
139- const uint8_t op,
139+ const LocationAtom op,
140140 const DWARFUnit *dwarf_cu) {
141141 lldb::offset_t offset = data_offset;
142142 switch (op) {
143+ // Only used in LLVM metadata.
144+ case DW_OP_LLVM_fragment:
145+ case DW_OP_LLVM_convert:
146+ case DW_OP_LLVM_tag_offset:
147+ case DW_OP_LLVM_entry_value:
148+ case DW_OP_LLVM_implicit_pointer:
149+ case DW_OP_LLVM_arg:
150+ case DW_OP_LLVM_extract_bits_sext:
151+ case DW_OP_LLVM_extract_bits_zext:
152+ break ;
153+ // Vendor extensions:
154+ case DW_OP_HP_is_value:
155+ case DW_OP_HP_fltconst4:
156+ case DW_OP_HP_fltconst8:
157+ case DW_OP_HP_mod_range:
158+ case DW_OP_HP_unmod_range:
159+ case DW_OP_HP_tls:
160+ case DW_OP_INTEL_bit_piece:
161+ case DW_OP_WASM_location:
162+ case DW_OP_WASM_location_int:
163+ case DW_OP_APPLE_uninit:
164+ case DW_OP_PGI_omp_thread_num:
165+ case DW_OP_hi_user:
166+ break ;
167+
143168 case DW_OP_addr:
144169 case DW_OP_call_ref: // 0x9a 1 address sized offset of DIE (DWARF3)
145170 return data.GetAddressByteSize ();
@@ -250,6 +275,7 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
250275 case DW_OP_pick: // 0x15 1 1-byte stack index
251276 case DW_OP_deref_size: // 0x94 1 1-byte size of data retrieved
252277 case DW_OP_xderef_size: // 0x95 1 1-byte size of data retrieved
278+ case DW_OP_deref_type: // 0xa6 1 1-byte constant
253279 return 1 ;
254280
255281 // Opcodes with a single 2 byte arguments
@@ -272,7 +298,6 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
272298 return 8 ;
273299
274300 // All opcodes that have a single ULEB (signed or unsigned) argument
275- case DW_OP_addrx: // 0xa1 1 ULEB128 index
276301 case DW_OP_constu: // 0x10 1 ULEB128 constant
277302 case DW_OP_consts: // 0x11 1 SLEB128 constant
278303 case DW_OP_plus_uconst: // 0x23 1 ULEB128 addend
@@ -311,14 +336,20 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
311336 case DW_OP_regx: // 0x90 1 ULEB128 register
312337 case DW_OP_fbreg: // 0x91 1 SLEB128 offset
313338 case DW_OP_piece: // 0x93 1 ULEB128 size of piece addressed
339+ case DW_OP_convert: // 0xa8 1 ULEB128 offset
340+ case DW_OP_reinterpret: // 0xa9 1 ULEB128 offset
341+ case DW_OP_addrx: // 0xa1 1 ULEB128 index
342+ case DW_OP_constx: // 0xa2 1 ULEB128 index
343+ case DW_OP_xderef_type: // 0xa7 1 ULEB128 index
314344 case DW_OP_GNU_addr_index: // 0xfb 1 ULEB128 index
315345 case DW_OP_GNU_const_index: // 0xfc 1 ULEB128 index
316346 data.Skip_LEB128 (&offset);
317347 return offset - data_offset;
318348
319349 // All opcodes that have a 2 ULEB (signed or unsigned) arguments
320- case DW_OP_bregx: // 0x92 2 ULEB128 register followed by SLEB128 offset
321- case DW_OP_bit_piece: // 0x9d ULEB128 bit size, ULEB128 bit offset (DWARF3);
350+ case DW_OP_bregx: // 0x92 2 ULEB128 register followed by SLEB128 offset
351+ case DW_OP_bit_piece: // 0x9d ULEB128 bit size, ULEB128 bit offset (DWARF3);
352+ case DW_OP_regval_type: // 0xa5 ULEB128 + ULEB128
322353 data.Skip_LEB128 (&offset);
323354 data.Skip_LEB128 (&offset);
324355 return offset - data_offset;
@@ -331,28 +362,47 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
331362 return offset - data_offset;
332363 }
333364
365+ case DW_OP_implicit_pointer: // 0xa0 4-byte (or 8-byte for DWARF 64) constant
366+ // + LEB128
367+ {
368+ data.Skip_LEB128 (&offset);
369+ return DWARFUnit::GetAddressByteSize (dwarf_cu) + offset - data_offset;
370+ }
371+
334372 case DW_OP_GNU_entry_value:
335373 case DW_OP_entry_value: // 0xa3 ULEB128 size + variable-length block
336374 {
337375 uint64_t subexpr_len = data.GetULEB128 (&offset);
338376 return (offset - data_offset) + subexpr_len;
339377 }
340378
341- default :
342- if (!dwarf_cu) {
343- return LLDB_INVALID_OFFSET;
344- }
379+ case DW_OP_const_type: // 0xa4 ULEB128 + size + variable-length block
380+ {
381+ data.Skip_LEB128 (&offset);
382+ uint8_t length = data.GetU8 (&offset);
383+ return (offset - data_offset) + length;
384+ }
385+
386+ case DW_OP_LLVM_user: // 0xe9: ULEB128 + variable length constant
387+ {
388+ uint64_t constants = data.GetULEB128 (&offset);
389+ return (offset - data_offset) + constants;
390+ }
391+ }
392+
393+ if (dwarf_cu)
345394 return dwarf_cu->GetSymbolFileDWARF ().GetVendorDWARFOpcodeSize (
346395 data, data_offset, op);
347- }
396+
397+ return LLDB_INVALID_OFFSET;
348398}
349399
350400lldb::addr_t DWARFExpression::GetLocation_DW_OP_addr (const DWARFUnit *dwarf_cu,
351401 bool &error) const {
352402 error = false ;
353403 lldb::offset_t offset = 0 ;
354404 while (m_data.ValidOffset (offset)) {
355- const uint8_t op = m_data.GetU8 (&offset);
405+ const LocationAtom op = static_cast <LocationAtom>( m_data.GetU8 (&offset) );
356406
357407 if (op == DW_OP_addr)
358408 return m_data.GetAddress (&offset);
@@ -378,7 +428,7 @@ bool DWARFExpression::Update_DW_OP_addr(const DWARFUnit *dwarf_cu,
378428 lldb::addr_t file_addr) {
379429 lldb::offset_t offset = 0 ;
380430 while (m_data.ValidOffset (offset)) {
381- const uint8_t op = m_data.GetU8 (&offset);
431+ const LocationAtom op = static_cast <LocationAtom>( m_data.GetU8 (&offset) );
382432
383433 if (op == DW_OP_addr) {
384434 const uint32_t addr_byte_size = m_data.GetAddressByteSize ();
@@ -436,7 +486,7 @@ bool DWARFExpression::ContainsThreadLocalStorage(
436486 const DWARFUnit *dwarf_cu) const {
437487 lldb::offset_t offset = 0 ;
438488 while (m_data.ValidOffset (offset)) {
439- const uint8_t op = m_data.GetU8 (&offset);
489+ const LocationAtom op = static_cast <LocationAtom>( m_data.GetU8 (&offset) );
440490
441491 if (op == DW_OP_form_tls_address || op == DW_OP_GNU_push_tls_address)
442492 return true ;
@@ -467,7 +517,7 @@ bool DWARFExpression::LinkThreadLocalStorage(
467517 lldb::addr_t const_value = 0 ;
468518 size_t const_byte_size = 0 ;
469519 while (m_data.ValidOffset (offset)) {
470- const uint8_t op = m_data.GetU8 (&offset);
520+ const LocationAtom op = static_cast <LocationAtom>( m_data.GetU8 (&offset) );
471521
472522 bool decoded_data = false ;
473523 switch (op) {
0 commit comments