@@ -132,10 +132,35 @@ static llvm::Error ReadRegisterValueAsScalar(RegisterContext *reg_ctx,
132
132
// / are made on the state of \p data after this call.
133
133
static lldb::offset_t GetOpcodeDataSize (const DataExtractor &data,
134
134
const lldb::offset_t data_offset,
135
- const uint8_t op,
135
+ const LocationAtom op,
136
136
const DWARFUnit *dwarf_cu) {
137
137
lldb::offset_t offset = data_offset;
138
138
switch (op) {
139
+ // Only used in LLVM metadata.
140
+ case DW_OP_LLVM_fragment:
141
+ case DW_OP_LLVM_convert:
142
+ case DW_OP_LLVM_tag_offset:
143
+ case DW_OP_LLVM_entry_value:
144
+ case DW_OP_LLVM_implicit_pointer:
145
+ case DW_OP_LLVM_arg:
146
+ case DW_OP_LLVM_extract_bits_sext:
147
+ case DW_OP_LLVM_extract_bits_zext:
148
+ break ;
149
+ // Vendor extensions:
150
+ case DW_OP_HP_is_value:
151
+ case DW_OP_HP_fltconst4:
152
+ case DW_OP_HP_fltconst8:
153
+ case DW_OP_HP_mod_range:
154
+ case DW_OP_HP_unmod_range:
155
+ case DW_OP_HP_tls:
156
+ case DW_OP_INTEL_bit_piece:
157
+ case DW_OP_WASM_location:
158
+ case DW_OP_WASM_location_int:
159
+ case DW_OP_APPLE_uninit:
160
+ case DW_OP_PGI_omp_thread_num:
161
+ case DW_OP_hi_user:
162
+ break ;
163
+
139
164
case DW_OP_addr:
140
165
case DW_OP_call_ref: // 0x9a 1 address sized offset of DIE (DWARF3)
141
166
return data.GetAddressByteSize ();
@@ -246,6 +271,7 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
246
271
case DW_OP_pick: // 0x15 1 1-byte stack index
247
272
case DW_OP_deref_size: // 0x94 1 1-byte size of data retrieved
248
273
case DW_OP_xderef_size: // 0x95 1 1-byte size of data retrieved
274
+ case DW_OP_deref_type: // 0xa6 1 1-byte constant
249
275
return 1 ;
250
276
251
277
// Opcodes with a single 2 byte arguments
@@ -268,7 +294,6 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
268
294
return 8 ;
269
295
270
296
// All opcodes that have a single ULEB (signed or unsigned) argument
271
- case DW_OP_addrx: // 0xa1 1 ULEB128 index
272
297
case DW_OP_constu: // 0x10 1 ULEB128 constant
273
298
case DW_OP_consts: // 0x11 1 SLEB128 constant
274
299
case DW_OP_plus_uconst: // 0x23 1 ULEB128 addend
@@ -307,14 +332,20 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
307
332
case DW_OP_regx: // 0x90 1 ULEB128 register
308
333
case DW_OP_fbreg: // 0x91 1 SLEB128 offset
309
334
case DW_OP_piece: // 0x93 1 ULEB128 size of piece addressed
335
+ case DW_OP_convert: // 0xa8 1 ULEB128 offset
336
+ case DW_OP_reinterpret: // 0xa9 1 ULEB128 offset
337
+ case DW_OP_addrx: // 0xa1 1 ULEB128 index
338
+ case DW_OP_constx: // 0xa2 1 ULEB128 index
339
+ case DW_OP_xderef_type: // 0xa7 1 ULEB128 index
310
340
case DW_OP_GNU_addr_index: // 0xfb 1 ULEB128 index
311
341
case DW_OP_GNU_const_index: // 0xfc 1 ULEB128 index
312
342
data.Skip_LEB128 (&offset);
313
343
return offset - data_offset;
314
344
315
345
// All opcodes that have a 2 ULEB (signed or unsigned) arguments
316
- case DW_OP_bregx: // 0x92 2 ULEB128 register followed by SLEB128 offset
317
- case DW_OP_bit_piece: // 0x9d ULEB128 bit size, ULEB128 bit offset (DWARF3);
346
+ case DW_OP_bregx: // 0x92 2 ULEB128 register followed by SLEB128 offset
347
+ case DW_OP_bit_piece: // 0x9d ULEB128 bit size, ULEB128 bit offset (DWARF3);
348
+ case DW_OP_regval_type: // 0xa5 ULEB128 + ULEB128
318
349
data.Skip_LEB128 (&offset);
319
350
data.Skip_LEB128 (&offset);
320
351
return offset - data_offset;
@@ -327,27 +358,46 @@ static lldb::offset_t GetOpcodeDataSize(const DataExtractor &data,
327
358
return offset - data_offset;
328
359
}
329
360
361
+ case DW_OP_implicit_pointer: // 0xa0 4-byte (or 8-byte for DWARF 64) constant
362
+ // + LEB128
363
+ {
364
+ data.Skip_LEB128 (&offset);
365
+ return DWARFUnit::GetAddressByteSize (dwarf_cu) + offset - data_offset;
366
+ }
367
+
330
368
case DW_OP_GNU_entry_value:
331
369
case DW_OP_entry_value: // 0xa3 ULEB128 size + variable-length block
332
370
{
333
371
uint64_t subexpr_len = data.GetULEB128 (&offset);
334
372
return (offset - data_offset) + subexpr_len;
335
373
}
336
374
337
- default :
338
- if (!dwarf_cu) {
339
- return LLDB_INVALID_OFFSET;
340
- }
375
+ case DW_OP_const_type: // 0xa4 ULEB128 + size + variable-length block
376
+ {
377
+ data.Skip_LEB128 (&offset);
378
+ uint8_t length = data.GetU8 (&offset);
379
+ return (offset - data_offset) + length;
380
+ }
381
+
382
+ case DW_OP_LLVM_user: // 0xe9: ULEB128 + variable length constant
383
+ {
384
+ uint64_t constants = data.GetULEB128 (&offset);
385
+ return (offset - data_offset) + constants;
386
+ }
387
+ }
388
+
389
+ if (dwarf_cu)
341
390
return dwarf_cu->GetSymbolFileDWARF ().GetVendorDWARFOpcodeSize (
342
391
data, data_offset, op);
343
- }
392
+
393
+ return LLDB_INVALID_OFFSET;
344
394
}
345
395
346
396
llvm::Expected<lldb::addr_t >
347
397
DWARFExpression::GetLocation_DW_OP_addr (const DWARFUnit *dwarf_cu) const {
348
398
lldb::offset_t offset = 0 ;
349
399
while (m_data.ValidOffset (offset)) {
350
- const uint8_t op = m_data.GetU8 (&offset);
400
+ const LocationAtom op = static_cast <LocationAtom>( m_data.GetU8 (&offset) );
351
401
352
402
if (op == DW_OP_addr)
353
403
return m_data.GetAddress (&offset);
@@ -376,7 +426,7 @@ bool DWARFExpression::Update_DW_OP_addr(const DWARFUnit *dwarf_cu,
376
426
lldb::addr_t file_addr) {
377
427
lldb::offset_t offset = 0 ;
378
428
while (m_data.ValidOffset (offset)) {
379
- const uint8_t op = m_data.GetU8 (&offset);
429
+ const LocationAtom op = static_cast <LocationAtom>( m_data.GetU8 (&offset) );
380
430
381
431
if (op == DW_OP_addr) {
382
432
const uint32_t addr_byte_size = m_data.GetAddressByteSize ();
@@ -434,7 +484,7 @@ bool DWARFExpression::ContainsThreadLocalStorage(
434
484
const DWARFUnit *dwarf_cu) const {
435
485
lldb::offset_t offset = 0 ;
436
486
while (m_data.ValidOffset (offset)) {
437
- const uint8_t op = m_data.GetU8 (&offset);
487
+ const LocationAtom op = static_cast <LocationAtom>( m_data.GetU8 (&offset) );
438
488
439
489
if (op == DW_OP_form_tls_address || op == DW_OP_GNU_push_tls_address)
440
490
return true ;
@@ -465,7 +515,7 @@ bool DWARFExpression::LinkThreadLocalStorage(
465
515
lldb::addr_t const_value = 0 ;
466
516
size_t const_byte_size = 0 ;
467
517
while (m_data.ValidOffset (offset)) {
468
- const uint8_t op = m_data.GetU8 (&offset);
518
+ const LocationAtom op = static_cast <LocationAtom>( m_data.GetU8 (&offset) );
469
519
470
520
bool decoded_data = false ;
471
521
switch (op) {
0 commit comments