Coverage Report

Created: 2022-01-25 06:29

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp
Line
Count
Source (jump to first uncovered line)
1
//===-- DWARFFormValue.cpp ------------------------------------------------===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#include <cassert>
10
11
#include "lldb/Core/Module.h"
12
#include "lldb/Core/dwarf.h"
13
#include "lldb/Symbol/ObjectFile.h"
14
#include "lldb/Utility/Stream.h"
15
16
#include "DWARFDebugInfo.h"
17
#include "DWARFFormValue.h"
18
#include "DWARFUnit.h"
19
20
class DWARFUnit;
21
22
using namespace lldb_private;
23
24
521
void DWARFFormValue::Clear() {
25
521
  m_unit = nullptr;
26
521
  m_form = 0;
27
521
  m_value = ValueTypeTag();
28
521
}
29
30
bool DWARFFormValue::ExtractValue(const DWARFDataExtractor &data,
31
2.46M
                                  lldb::offset_t *offset_ptr) {
32
2.46M
  if (m_form == DW_FORM_implicit_const)
33
2
    return true;
34
35
2.46M
  bool indirect = false;
36
2.46M
  bool is_block = false;
37
2.46M
  m_value.data = nullptr;
38
2.46M
  uint8_t ref_addr_size;
39
  // Read the value for the form into value and follow and DW_FORM_indirect
40
  // instances we run into
41
2.46M
  do {
42
2.46M
    indirect = false;
43
2.46M
    switch (m_form) {
44
148k
    case DW_FORM_addr:
45
148k
      assert(m_unit);
46
0
      m_value.value.uval =
47
148k
          data.GetMaxU64(offset_ptr, DWARFUnit::GetAddressByteSize(m_unit));
48
148k
      break;
49
0
    case DW_FORM_block1:
50
0
      m_value.value.uval = data.GetU8(offset_ptr);
51
0
      is_block = true;
52
0
      break;
53
0
    case DW_FORM_block2:
54
0
      m_value.value.uval = data.GetU16(offset_ptr);
55
0
      is_block = true;
56
0
      break;
57
0
    case DW_FORM_block4:
58
0
      m_value.value.uval = data.GetU32(offset_ptr);
59
0
      is_block = true;
60
0
      break;
61
0
    case DW_FORM_data16:
62
0
      m_value.value.uval = 16;
63
0
      is_block = true;
64
0
      break;
65
49.9k
    case DW_FORM_exprloc:
66
49.9k
    case DW_FORM_block:
67
49.9k
      m_value.value.uval = data.GetULEB128(offset_ptr);
68
49.9k
      is_block = true;
69
49.9k
      break;
70
633
    case DW_FORM_string:
71
633
      m_value.value.cstr = data.GetCStr(offset_ptr);
72
633
      break;
73
1.14k
    case DW_FORM_sdata:
74
1.14k
      m_value.value.sval = data.GetSLEB128(offset_ptr);
75
1.14k
      break;
76
576k
    case DW_FORM_strp:
77
576k
    case DW_FORM_line_strp:
78
599k
    case DW_FORM_sec_offset:
79
599k
      m_value.value.uval = data.GetMaxU64(offset_ptr, 4);
80
599k
      break;
81
0
    case DW_FORM_addrx1:
82
307
    case DW_FORM_strx1:
83
307
    case DW_FORM_ref1:
84
352k
    case DW_FORM_data1:
85
352k
    case DW_FORM_flag:
86
352k
      m_value.value.uval = data.GetU8(offset_ptr);
87
352k
      break;
88
0
    case DW_FORM_addrx2:
89
0
    case DW_FORM_strx2:
90
0
    case DW_FORM_ref2:
91
116k
    case DW_FORM_data2:
92
116k
      m_value.value.uval = data.GetU16(offset_ptr);
93
116k
      break;
94
0
    case DW_FORM_addrx3:
95
0
    case DW_FORM_strx3:
96
0
      m_value.value.uval = data.GetMaxU64(offset_ptr, 3);
97
0
      break;
98
0
    case DW_FORM_addrx4:
99
0
    case DW_FORM_strx4:
100
239k
    case DW_FORM_ref4:
101
842k
    case DW_FORM_data4:
102
842k
      m_value.value.uval = data.GetU32(offset_ptr);
103
842k
      break;
104
24.0k
    case DW_FORM_data8:
105
24.0k
    case DW_FORM_ref8:
106
24.0k
    case DW_FORM_ref_sig8:
107
24.0k
      m_value.value.uval = data.GetU64(offset_ptr);
108
24.0k
      break;
109
132
    case DW_FORM_addrx:
110
144
    case DW_FORM_loclistx:
111
179
    case DW_FORM_rnglistx:
112
179
    case DW_FORM_strx:
113
3.72k
    case DW_FORM_udata:
114
3.72k
    case DW_FORM_ref_udata:
115
3.73k
    case DW_FORM_GNU_str_index:
116
3.77k
    case DW_FORM_GNU_addr_index:
117
3.77k
      m_value.value.uval = data.GetULEB128(offset_ptr);
118
3.77k
      break;
119
94.5k
    case DW_FORM_ref_addr:
120
94.5k
      assert(m_unit);
121
94.5k
      if (m_unit->GetVersion() <= 2)
122
0
        ref_addr_size = m_unit->GetAddressByteSize();
123
94.5k
      else
124
94.5k
        ref_addr_size = 4;
125
94.5k
      m_value.value.uval = data.GetMaxU64(offset_ptr, ref_addr_size);
126
94.5k
      break;
127
0
    case DW_FORM_indirect:
128
0
      m_form = data.GetULEB128(offset_ptr);
129
0
      indirect = true;
130
0
      break;
131
232k
    case DW_FORM_flag_present:
132
232k
      m_value.value.uval = 1;
133
232k
      break;
134
0
    default:
135
0
      return false;
136
2.46M
    }
137
2.46M
  } while (indirect);
138
139
2.46M
  if (is_block) {
140
49.9k
    m_value.data = data.PeekData(*offset_ptr, m_value.value.uval);
141
49.9k
    if (m_value.data != nullptr) {
142
49.9k
      *offset_ptr += m_value.value.uval;
143
49.9k
    }
144
49.9k
  }
145
146
2.46M
  return true;
147
2.46M
}
148
149
struct FormSize {
150
  uint8_t valid:1, size:7;
151
};
152
static FormSize g_form_sizes[] = {
153
    {0, 0}, // 0x00 unused
154
    {0, 0}, // 0x01 DW_FORM_addr
155
    {0, 0}, // 0x02 unused
156
    {0, 0}, // 0x03 DW_FORM_block2
157
    {0, 0}, // 0x04 DW_FORM_block4
158
    {1, 2}, // 0x05 DW_FORM_data2
159
    {1, 4}, // 0x06 DW_FORM_data4
160
    {1, 8}, // 0x07 DW_FORM_data8
161
    {0, 0}, // 0x08 DW_FORM_string
162
    {0, 0}, // 0x09 DW_FORM_block
163
    {0, 0}, // 0x0a DW_FORM_block1
164
    {1, 1}, // 0x0b DW_FORM_data1
165
    {1, 1}, // 0x0c DW_FORM_flag
166
    {0, 0}, // 0x0d DW_FORM_sdata
167
    {1, 4}, // 0x0e DW_FORM_strp
168
    {0, 0}, // 0x0f DW_FORM_udata
169
    {0, 0}, // 0x10 DW_FORM_ref_addr (addr size for DWARF2 and earlier, 4 bytes
170
            // for DWARF32, 8 bytes for DWARF32 in DWARF 3 and later
171
    {1, 1},  // 0x11 DW_FORM_ref1
172
    {1, 2},  // 0x12 DW_FORM_ref2
173
    {1, 4},  // 0x13 DW_FORM_ref4
174
    {1, 8},  // 0x14 DW_FORM_ref8
175
    {0, 0},  // 0x15 DW_FORM_ref_udata
176
    {0, 0},  // 0x16 DW_FORM_indirect
177
    {1, 4},  // 0x17 DW_FORM_sec_offset
178
    {0, 0},  // 0x18 DW_FORM_exprloc
179
    {1, 0},  // 0x19 DW_FORM_flag_present
180
    {0, 0},  // 0x1a DW_FORM_strx (ULEB128)
181
    {0, 0},  // 0x1b DW_FORM_addrx (ULEB128)
182
    {1, 4},  // 0x1c DW_FORM_ref_sup4
183
    {0, 0},  // 0x1d DW_FORM_strp_sup (4 bytes for DWARF32, 8 bytes for DWARF64)
184
    {1, 16}, // 0x1e DW_FORM_data16
185
    {1, 4},  // 0x1f DW_FORM_line_strp
186
    {1, 8},  // 0x20 DW_FORM_ref_sig8
187
};
188
189
llvm::Optional<uint8_t>
190
19.7M
DWARFFormValue::GetFixedSize(dw_form_t form, const DWARFUnit *u) {
191
19.7M
  if (form <= DW_FORM_ref_sig8 && 
g_form_sizes[form].valid19.7M
)
192
18.1M
    return g_form_sizes[form].size;
193
1.65M
  if (form == DW_FORM_addr && 
u130k
)
194
130k
    return u->GetAddressByteSize();
195
1.52M
  return llvm::None;
196
1.65M
}
197
198
0
llvm::Optional<uint8_t> DWARFFormValue::GetFixedSize() const {
199
0
  return GetFixedSize(m_form, m_unit);
200
0
}
201
202
bool DWARFFormValue::SkipValue(const DWARFDataExtractor &debug_info_data,
203
0
                               lldb::offset_t *offset_ptr) const {
204
0
  return DWARFFormValue::SkipValue(m_form, debug_info_data, offset_ptr, m_unit);
205
0
}
206
207
bool DWARFFormValue::SkipValue(dw_form_t form,
208
                               const DWARFDataExtractor &debug_info_data,
209
                               lldb::offset_t *offset_ptr,
210
643k
                               const DWARFUnit *unit) {
211
643k
  uint8_t ref_addr_size;
212
643k
  switch (form) {
213
  // Blocks if inlined data that have a length field and the data bytes inlined
214
  // in the .debug_info
215
125k
  case DW_FORM_exprloc:
216
125k
  case DW_FORM_block: {
217
125k
    dw_uleb128_t size = debug_info_data.GetULEB128(offset_ptr);
218
125k
    *offset_ptr += size;
219
125k
  }
220
125k
    return true;
221
0
  case DW_FORM_block1: {
222
0
    dw_uleb128_t size = debug_info_data.GetU8(offset_ptr);
223
0
    *offset_ptr += size;
224
0
  }
225
0
    return true;
226
0
  case DW_FORM_block2: {
227
0
    dw_uleb128_t size = debug_info_data.GetU16(offset_ptr);
228
0
    *offset_ptr += size;
229
0
  }
230
0
    return true;
231
0
  case DW_FORM_block4: {
232
0
    dw_uleb128_t size = debug_info_data.GetU32(offset_ptr);
233
0
    *offset_ptr += size;
234
0
  }
235
0
    return true;
236
237
  // Inlined NULL terminated C-strings
238
787
  case DW_FORM_string:
239
787
    debug_info_data.GetCStr(offset_ptr);
240
787
    return true;
241
242
  // Compile unit address sized values
243
124k
  case DW_FORM_addr:
244
124k
    *offset_ptr += DWARFUnit::GetAddressByteSize(unit);
245
124k
    return true;
246
247
83.9k
  case DW_FORM_ref_addr:
248
83.9k
    ref_addr_size = 4;
249
83.9k
    assert(unit); // Unit must be valid for DW_FORM_ref_addr objects or we will
250
                  // get this wrong
251
83.9k
    if (unit->GetVersion() <= 2)
252
0
      ref_addr_size = unit->GetAddressByteSize();
253
83.9k
    else
254
83.9k
      ref_addr_size = 4;
255
83.9k
    *offset_ptr += ref_addr_size;
256
83.9k
    return true;
257
258
  // 0 bytes values (implied from DW_FORM)
259
4.06k
  case DW_FORM_flag_present:
260
4.07k
  case DW_FORM_implicit_const:
261
4.07k
    return true;
262
263
    // 1 byte values
264
0
    case DW_FORM_addrx1:
265
29.8k
    case DW_FORM_data1:
266
29.8k
    case DW_FORM_flag:
267
29.8k
    case DW_FORM_ref1:
268
30.1k
    case DW_FORM_strx1:
269
30.1k
      *offset_ptr += 1;
270
30.1k
      return true;
271
272
    // 2 byte values
273
0
    case DW_FORM_addrx2:
274
52.5k
    case DW_FORM_data2:
275
52.5k
    case DW_FORM_ref2:
276
52.5k
    case DW_FORM_strx2:
277
52.5k
      *offset_ptr += 2;
278
52.5k
      return true;
279
280
    // 3 byte values
281
0
    case DW_FORM_addrx3:
282
0
    case DW_FORM_strx3:
283
0
      *offset_ptr += 3;
284
0
      return true;
285
286
    // 32 bit for DWARF 32, 64 for DWARF 64
287
33.8k
    case DW_FORM_sec_offset:
288
182k
    case DW_FORM_strp:
289
182k
    case DW_FORM_line_strp:
290
182k
      *offset_ptr += 4;
291
182k
      return true;
292
293
    // 4 byte values
294
0
    case DW_FORM_addrx4:
295
6.06k
    case DW_FORM_data4:
296
24.5k
    case DW_FORM_ref4:
297
24.5k
    case DW_FORM_strx4:
298
24.5k
      *offset_ptr += 4;
299
24.5k
      return true;
300
301
    // 8 byte values
302
9.83k
    case DW_FORM_data8:
303
9.83k
    case DW_FORM_ref8:
304
9.83k
    case DW_FORM_ref_sig8:
305
9.83k
      *offset_ptr += 8;
306
9.83k
      return true;
307
308
    // signed or unsigned LEB 128 values
309
124
    case DW_FORM_addrx:
310
136
    case DW_FORM_loclistx:
311
143
    case DW_FORM_rnglistx:
312
1.29k
    case DW_FORM_sdata:
313
4.92k
    case DW_FORM_udata:
314
4.92k
    case DW_FORM_ref_udata:
315
4.95k
    case DW_FORM_GNU_addr_index:
316
4.97k
    case DW_FORM_GNU_str_index:
317
4.97k
    case DW_FORM_strx:
318
4.97k
      debug_info_data.Skip_LEB128(offset_ptr);
319
4.97k
      return true;
320
321
0
  case DW_FORM_indirect: {
322
0
    dw_form_t indirect_form = debug_info_data.GetULEB128(offset_ptr);
323
0
    return DWARFFormValue::SkipValue(indirect_form, debug_info_data, offset_ptr,
324
0
                                     unit);
325
4.97k
  }
326
327
0
  default:
328
0
    break;
329
643k
  }
330
0
  return false;
331
643k
}
332
333
0
void DWARFFormValue::Dump(Stream &s) const {
334
0
  uint64_t uvalue = Unsigned();
335
0
  bool unit_relative_offset = false;
336
337
0
  switch (m_form) {
338
0
  case DW_FORM_addr:
339
0
    DumpAddress(s.AsRawOstream(), uvalue, sizeof(uint64_t));
340
0
    break;
341
0
  case DW_FORM_flag:
342
0
  case DW_FORM_data1:
343
0
    s.PutHex8(uvalue);
344
0
    break;
345
0
  case DW_FORM_data2:
346
0
    s.PutHex16(uvalue);
347
0
    break;
348
0
  case DW_FORM_sec_offset:
349
0
  case DW_FORM_data4:
350
0
    s.PutHex32(uvalue);
351
0
    break;
352
0
  case DW_FORM_ref_sig8:
353
0
  case DW_FORM_data8:
354
0
    s.PutHex64(uvalue);
355
0
    break;
356
0
  case DW_FORM_string:
357
0
    s.QuotedCString(AsCString());
358
0
    break;
359
0
  case DW_FORM_exprloc:
360
0
  case DW_FORM_block:
361
0
  case DW_FORM_block1:
362
0
  case DW_FORM_block2:
363
0
  case DW_FORM_block4:
364
0
    if (uvalue > 0) {
365
0
      switch (m_form) {
366
0
      case DW_FORM_exprloc:
367
0
      case DW_FORM_block:
368
0
        s.Printf("<0x%" PRIx64 "> ", uvalue);
369
0
        break;
370
0
      case DW_FORM_block1:
371
0
        s.Printf("<0x%2.2x> ", (uint8_t)uvalue);
372
0
        break;
373
0
      case DW_FORM_block2:
374
0
        s.Printf("<0x%4.4x> ", (uint16_t)uvalue);
375
0
        break;
376
0
      case DW_FORM_block4:
377
0
        s.Printf("<0x%8.8x> ", (uint32_t)uvalue);
378
0
        break;
379
0
      default:
380
0
        break;
381
0
      }
382
383
0
      const uint8_t *data_ptr = m_value.data;
384
0
      if (data_ptr) {
385
0
        const uint8_t *end_data_ptr =
386
0
            data_ptr + uvalue; // uvalue contains size of block
387
0
        while (data_ptr < end_data_ptr) {
388
0
          s.Printf("%2.2x ", *data_ptr);
389
0
          ++data_ptr;
390
0
        }
391
0
      } else
392
0
        s.PutCString("NULL");
393
0
    }
394
0
    break;
395
396
0
  case DW_FORM_sdata:
397
0
    s.PutSLEB128(uvalue);
398
0
    break;
399
0
  case DW_FORM_udata:
400
0
    s.PutULEB128(uvalue);
401
0
    break;
402
0
  case DW_FORM_strp:
403
0
  case DW_FORM_line_strp: {
404
0
    const char *dbg_str = AsCString();
405
0
    if (dbg_str) {
406
0
      s.QuotedCString(dbg_str);
407
0
    } else {
408
0
      s.PutHex32(uvalue);
409
0
    }
410
0
  } break;
411
412
0
  case DW_FORM_ref_addr: {
413
0
    assert(m_unit); // Unit must be valid for DW_FORM_ref_addr objects or we
414
                    // will get this wrong
415
0
    if (m_unit->GetVersion() <= 2)
416
0
      DumpAddress(s.AsRawOstream(), uvalue, sizeof(uint64_t) * 2);
417
0
    else
418
0
      DumpAddress(s.AsRawOstream(), uvalue,
419
0
                  4 * 2); // 4 for DWARF32, 8 for DWARF64, but we don't
420
                          // support DWARF64 yet
421
0
    break;
422
0
  }
423
0
  case DW_FORM_ref1:
424
0
    unit_relative_offset = true;
425
0
    break;
426
0
  case DW_FORM_ref2:
427
0
    unit_relative_offset = true;
428
0
    break;
429
0
  case DW_FORM_ref4:
430
0
    unit_relative_offset = true;
431
0
    break;
432
0
  case DW_FORM_ref8:
433
0
    unit_relative_offset = true;
434
0
    break;
435
0
  case DW_FORM_ref_udata:
436
0
    unit_relative_offset = true;
437
0
    break;
438
439
  // All DW_FORM_indirect attributes should be resolved prior to calling this
440
  // function
441
0
  case DW_FORM_indirect:
442
0
    s.PutCString("DW_FORM_indirect");
443
0
    break;
444
0
  case DW_FORM_flag_present:
445
0
    break;
446
0
  default:
447
0
    s.Printf("DW_FORM(0x%4.4x)", m_form);
448
0
    break;
449
0
  }
450
451
0
  if (unit_relative_offset) {
452
0
    assert(m_unit); // Unit must be valid for DW_FORM_ref forms that are compile
453
                    // unit relative or we will get this wrong
454
0
    s.Printf("{0x%8.8" PRIx64 "}", uvalue + m_unit->GetOffset());
455
0
  }
456
0
}
457
458
489k
const char *DWARFFormValue::AsCString() const {
459
489k
  DWARFContext &context = m_unit->GetSymbolFileDWARF().GetDWARFContext();
460
461
489k
  if (m_form == DW_FORM_string)
462
550
    return m_value.value.cstr;
463
488k
  if (m_form == DW_FORM_strp)
464
488k
    return context.getOrLoadStrData().PeekCStr(m_value.value.uval);
465
466
242
  if (m_form == DW_FORM_GNU_str_index || 
m_form == DW_FORM_strx226
||
467
242
      
m_form == DW_FORM_strx1226
||
m_form == DW_FORM_strx21
||
468
242
      
m_form == DW_FORM_strx31
||
m_form == DW_FORM_strx41
) {
469
470
240
    llvm::Optional<uint64_t> offset =
471
240
        m_unit->GetStringOffsetSectionItem(m_value.value.uval);
472
240
    if (!offset)
473
0
      return nullptr;
474
240
    return context.getOrLoadStrData().PeekCStr(*offset);
475
240
  }
476
477
2
  if (m_form == DW_FORM_line_strp)
478
0
    return context.getOrLoadLineStrData().PeekCStr(m_value.value.uval);
479
480
2
  return nullptr;
481
2
}
482
483
145k
dw_addr_t DWARFFormValue::Address() const {
484
145k
  SymbolFileDWARF &symbol_file = m_unit->GetSymbolFileDWARF();
485
486
145k
  if (m_form == DW_FORM_addr)
487
145k
    return Unsigned();
488
489
167
  assert(m_unit);
490
0
  assert(m_form == DW_FORM_GNU_addr_index || m_form == DW_FORM_addrx ||
491
167
         m_form == DW_FORM_addrx1 || m_form == DW_FORM_addrx2 ||
492
167
         m_form == DW_FORM_addrx3 || m_form == DW_FORM_addrx4);
493
494
0
  uint32_t index_size = m_unit->GetAddressByteSize();
495
167
  dw_offset_t addr_base = m_unit->GetAddrBase();
496
167
  lldb::offset_t offset = addr_base + m_value.value.uval * index_size;
497
167
  return symbol_file.GetDWARFContext().getOrLoadAddrData().GetMaxU64(
498
167
      &offset, index_size);
499
145k
}
500
501
473k
DWARFDIE DWARFFormValue::Reference() const {
502
473k
  uint64_t value = m_value.value.uval;
503
473k
  switch (m_form) {
504
0
  case DW_FORM_ref1:
505
0
  case DW_FORM_ref2:
506
232k
  case DW_FORM_ref4:
507
232k
  case DW_FORM_ref8:
508
232k
  case DW_FORM_ref_udata:
509
232k
    assert(m_unit); // Unit must be valid for DW_FORM_ref forms that are compile
510
                    // unit relative or we will get this wrong
511
0
    value += m_unit->GetOffset();
512
232k
    if (!m_unit->ContainsDIEOffset(value)) {
513
0
      m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
514
0
          "DW_FORM_ref* DIE reference 0x%" PRIx64 " is outside of its CU",
515
0
          value);
516
0
      return {};
517
0
    }
518
232k
    return const_cast<DWARFUnit *>(m_unit)->GetDIE(value);
519
520
95.1k
  case DW_FORM_ref_addr: {
521
95.1k
    DWARFUnit *ref_cu =
522
95.1k
        m_unit->GetSymbolFileDWARF().DebugInfo().GetUnitContainingDIEOffset(
523
95.1k
            DIERef::Section::DebugInfo, value);
524
95.1k
    if (!ref_cu) {
525
0
      m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
526
0
          "DW_FORM_ref_addr DIE reference 0x%" PRIx64 " has no matching CU",
527
0
          value);
528
0
      return {};
529
0
    }
530
95.1k
    return ref_cu->GetDIE(value);
531
95.1k
  }
532
533
12
  case DW_FORM_ref_sig8: {
534
12
    DWARFTypeUnit *tu =
535
12
        m_unit->GetSymbolFileDWARF().DebugInfo().GetTypeUnitForHash(value);
536
12
    if (!tu)
537
3
      return {};
538
9
    return tu->GetDIE(tu->GetTypeOffset());
539
12
  }
540
541
145k
  default:
542
145k
    return {};
543
473k
  }
544
473k
}
545
546
0
uint64_t DWARFFormValue::Reference(dw_offset_t base_offset) const {
547
0
  uint64_t value = m_value.value.uval;
548
0
  switch (m_form) {
549
0
  case DW_FORM_ref1:
550
0
  case DW_FORM_ref2:
551
0
  case DW_FORM_ref4:
552
0
  case DW_FORM_ref8:
553
0
  case DW_FORM_ref_udata:
554
0
    return value + base_offset;
555
556
0
  case DW_FORM_ref_addr:
557
0
  case DW_FORM_ref_sig8:
558
0
  case DW_FORM_GNU_ref_alt:
559
0
    return value;
560
561
0
  default:
562
0
    return DW_INVALID_OFFSET;
563
0
  }
564
0
}
565
566
61.5k
const uint8_t *DWARFFormValue::BlockData() const { return m_value.data; }
567
568
25.0k
bool DWARFFormValue::IsBlockForm(const dw_form_t form) {
569
25.0k
  switch (form) {
570
24.7k
  case DW_FORM_exprloc:
571
24.7k
  case DW_FORM_block:
572
24.7k
  case DW_FORM_block1:
573
24.7k
  case DW_FORM_block2:
574
24.7k
  case DW_FORM_block4:
575
24.7k
    return true;
576
25.0k
  }
577
276
  return false;
578
25.0k
}
579
580
455k
bool DWARFFormValue::IsDataForm(const dw_form_t form) {
581
455k
  switch (form) {
582
5
  case DW_FORM_sdata:
583
53
  case DW_FORM_udata:
584
54
  case DW_FORM_data1:
585
55
  case DW_FORM_data2:
586
455k
  case DW_FORM_data4:
587
455k
  case DW_FORM_data8:
588
455k
    return true;
589
455k
  }
590
3
  return false;
591
455k
}
592
593
1.09M
bool DWARFFormValue::FormIsSupported(dw_form_t form) {
594
1.09M
  switch (form) {
595
30.9k
    case DW_FORM_addr:
596
30.9k
    case DW_FORM_addrx:
597
31.0k
    case DW_FORM_loclistx:
598
31.0k
    case DW_FORM_rnglistx:
599
31.0k
    case DW_FORM_block2:
600
31.0k
    case DW_FORM_block4:
601
105k
    case DW_FORM_data2:
602
134k
    case DW_FORM_data4:
603
140k
    case DW_FORM_data8:
604
140k
    case DW_FORM_string:
605
140k
    case DW_FORM_block:
606
142k
    case DW_FORM_block1:
607
516k
    case DW_FORM_data1:
608
519k
    case DW_FORM_flag:
609
523k
    case DW_FORM_sdata:
610
789k
    case DW_FORM_strp:
611
789k
    case DW_FORM_line_strp:
612
789k
    case DW_FORM_strx:
613
789k
    case DW_FORM_strx1:
614
789k
    case DW_FORM_strx2:
615
789k
    case DW_FORM_strx3:
616
789k
    case DW_FORM_strx4:
617
799k
    case DW_FORM_udata:
618
817k
    case DW_FORM_ref_addr:
619
817k
    case DW_FORM_ref1:
620
817k
    case DW_FORM_ref2:
621
960k
    case DW_FORM_ref4:
622
960k
    case DW_FORM_ref8:
623
960k
    case DW_FORM_ref_udata:
624
960k
    case DW_FORM_indirect:
625
976k
    case DW_FORM_sec_offset:
626
1.01M
    case DW_FORM_exprloc:
627
1.09M
    case DW_FORM_flag_present:
628
1.09M
    case DW_FORM_ref_sig8:
629
1.09M
    case DW_FORM_GNU_str_index:
630
1.09M
    case DW_FORM_GNU_addr_index:
631
1.09M
    case DW_FORM_implicit_const:
632
1.09M
      return true;
633
0
    default:
634
0
      break;
635
1.09M
  }
636
0
  return false;
637
1.09M
}