@@ -136,10 +136,35 @@ static llvm::Error ReadRegisterValueAsScalar(RegisterContext *reg_ctx,
136
136
// / are made on the state of \p data after this call.
137
137
static lldb::offset_t GetOpcodeDataSize (const DataExtractor &data,
138
138
const lldb::offset_t data_offset,
139
- const uint8_t op,
139
+ const LocationAtom op,
140
140
const DWARFUnit *dwarf_cu) {
141
141
lldb::offset_t offset = data_offset;
142
142
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
+
143
168
case DW_OP_addr:
144
169
case DW_OP_call_ref: // 0x9a 1 address sized offset of DIE (DWARF3)
145
170
return data.GetAddressByteSize ();
@@ -250,6 +275,7 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
250
275
case DW_OP_pick: // 0x15 1 1-byte stack index
251
276
case DW_OP_deref_size: // 0x94 1 1-byte size of data retrieved
252
277
case DW_OP_xderef_size: // 0x95 1 1-byte size of data retrieved
278
+ case DW_OP_deref_type: // 0xa6 1 1-byte constant
253
279
return 1 ;
254
280
255
281
// Opcodes with a single 2 byte arguments
@@ -272,7 +298,6 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
272
298
return 8 ;
273
299
274
300
// All opcodes that have a single ULEB (signed or unsigned) argument
275
- case DW_OP_addrx: // 0xa1 1 ULEB128 index
276
301
case DW_OP_constu: // 0x10 1 ULEB128 constant
277
302
case DW_OP_consts: // 0x11 1 SLEB128 constant
278
303
case DW_OP_plus_uconst: // 0x23 1 ULEB128 addend
@@ -311,14 +336,20 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
311
336
case DW_OP_regx: // 0x90 1 ULEB128 register
312
337
case DW_OP_fbreg: // 0x91 1 SLEB128 offset
313
338
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
314
344
case DW_OP_GNU_addr_index: // 0xfb 1 ULEB128 index
315
345
case DW_OP_GNU_const_index: // 0xfc 1 ULEB128 index
316
346
data.Skip_LEB128 (&offset);
317
347
return offset - data_offset;
318
348
319
349
// 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
322
353
data.Skip_LEB128 (&offset);
323
354
data.Skip_LEB128 (&offset);
324
355
return offset - data_offset;
@@ -331,27 +362,46 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
331
362
return offset - data_offset;
332
363
}
333
364
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
+
334
372
case DW_OP_GNU_entry_value:
335
373
case DW_OP_entry_value: // 0xa3 ULEB128 size + variable-length block
336
374
{
337
375
uint64_t subexpr_len = data.GetULEB128 (&offset);
338
376
return (offset - data_offset) + subexpr_len;
339
377
}
340
378
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)
345
394
return dwarf_cu->GetSymbolFileDWARF ().GetVendorDWARFOpcodeSize (
346
395
data, data_offset, op);
347
- }
396
+
397
+ return LLDB_INVALID_OFFSET;
348
398
}
349
399
350
400
llvm::Expected<lldb::addr_t >
351
401
DWARFExpression::GetLocation_DW_OP_addr (const DWARFUnit *dwarf_cu) const {
352
402
lldb::offset_t offset = 0 ;
353
403
while (m_data.ValidOffset (offset)) {
354
- const uint8_t op = m_data.GetU8 (&offset);
404
+ const LocationAtom op = static_cast <LocationAtom>( m_data.GetU8 (&offset) );
355
405
356
406
if (op == DW_OP_addr)
357
407
return m_data.GetAddress (&offset);
@@ -380,7 +430,7 @@ bool DWARFExpression::Update_DW_OP_addr(const DWARFUnit *dwarf_cu,
380
430
lldb::addr_t file_addr) {
381
431
lldb::offset_t offset = 0 ;
382
432
while (m_data.ValidOffset (offset)) {
383
- const uint8_t op = m_data.GetU8 (&offset);
433
+ const LocationAtom op = static_cast <LocationAtom>( m_data.GetU8 (&offset) );
384
434
385
435
if (op == DW_OP_addr) {
386
436
const uint32_t addr_byte_size = m_data.GetAddressByteSize ();
@@ -438,7 +488,7 @@ bool DWARFExpression::ContainsThreadLocalStorage(
438
488
const DWARFUnit *dwarf_cu) const {
439
489
lldb::offset_t offset = 0 ;
440
490
while (m_data.ValidOffset (offset)) {
441
- const uint8_t op = m_data.GetU8 (&offset);
491
+ const LocationAtom op = static_cast <LocationAtom>( m_data.GetU8 (&offset) );
442
492
443
493
if (op == DW_OP_form_tls_address || op == DW_OP_GNU_push_tls_address)
444
494
return true ;
@@ -469,7 +519,7 @@ bool DWARFExpression::LinkThreadLocalStorage(
469
519
lldb::addr_t const_value = 0 ;
470
520
size_t const_byte_size = 0 ;
471
521
while (m_data.ValidOffset (offset)) {
472
- const uint8_t op = m_data.GetU8 (&offset);
522
+ const LocationAtom op = static_cast <LocationAtom>( m_data.GetU8 (&offset) );
473
523
474
524
bool decoded_data = false ;
475
525
switch (op) {
0 commit comments