LLDB mainline
DWARFFormValue.cpp
Go to the documentation of this file.
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#include <optional>
11
12#include "lldb/Core/Module.h"
13#include "lldb/Core/dwarf.h"
15#include "lldb/Utility/Stream.h"
16
17#include "DWARFDebugInfo.h"
18#include "DWARFFormValue.h"
19#include "DWARFUnit.h"
20
21using namespace lldb_private;
22using namespace lldb_private::plugin::dwarf;
23using namespace llvm::dwarf;
24
26 m_unit = nullptr;
27 m_form = dw_form_t(0);
29}
30
32 lldb::offset_t *offset_ptr) {
33 if (m_form == DW_FORM_implicit_const)
34 return true;
35
36 bool indirect = false;
37 bool is_block = false;
38 m_value.data = nullptr;
39 // Read the value for the form into value and follow and DW_FORM_indirect
40 // instances we run into
41 do {
42 indirect = false;
43 switch (m_form) {
44 case DW_FORM_addr:
45 assert(m_unit);
46 m_value.uval =
48 break;
49 case DW_FORM_block1:
50 m_value.uval = data.GetU8(offset_ptr);
51 is_block = true;
52 break;
53 case DW_FORM_block2:
54 m_value.uval = data.GetU16(offset_ptr);
55 is_block = true;
56 break;
57 case DW_FORM_block4:
58 m_value.uval = data.GetU32(offset_ptr);
59 is_block = true;
60 break;
61 case DW_FORM_data16:
62 m_value.uval = 16;
63 is_block = true;
64 break;
65 case DW_FORM_exprloc:
66 case DW_FORM_block:
67 m_value.uval = data.GetULEB128(offset_ptr);
68 is_block = true;
69 break;
70 case DW_FORM_string:
71 m_value.cstr = data.GetCStr(offset_ptr);
72 break;
73 case DW_FORM_sdata:
74 m_value.sval = data.GetSLEB128(offset_ptr);
75 break;
76 case DW_FORM_strp:
77 case DW_FORM_line_strp:
78 case DW_FORM_sec_offset:
79 case DW_FORM_GNU_ref_alt:
80 case DW_FORM_GNU_strp_alt:
81 assert(m_unit);
82 m_value.uval = data.GetMaxU64(
83 offset_ptr, m_unit->GetFormParams().getDwarfOffsetByteSize());
84 break;
85 case DW_FORM_addrx1:
86 case DW_FORM_strx1:
87 case DW_FORM_ref1:
88 case DW_FORM_data1:
89 case DW_FORM_flag:
90 m_value.uval = data.GetU8(offset_ptr);
91 break;
92 case DW_FORM_addrx2:
93 case DW_FORM_strx2:
94 case DW_FORM_ref2:
95 case DW_FORM_data2:
96 m_value.uval = data.GetU16(offset_ptr);
97 break;
98 case DW_FORM_addrx3:
99 case DW_FORM_strx3:
100 m_value.uval = data.GetMaxU64(offset_ptr, 3);
101 break;
102 case DW_FORM_addrx4:
103 case DW_FORM_strx4:
104 case DW_FORM_ref4:
105 case DW_FORM_data4:
106 m_value.uval = data.GetU32(offset_ptr);
107 break;
108 case DW_FORM_data8:
109 case DW_FORM_ref8:
110 case DW_FORM_ref_sig8:
111 m_value.uval = data.GetU64(offset_ptr);
112 break;
113 case DW_FORM_addrx:
114 case DW_FORM_loclistx:
115 case DW_FORM_rnglistx:
116 case DW_FORM_strx:
117 case DW_FORM_udata:
118 case DW_FORM_ref_udata:
119 case DW_FORM_GNU_str_index:
120 case DW_FORM_GNU_addr_index:
121 m_value.uval = data.GetULEB128(offset_ptr);
122 break;
123 case DW_FORM_ref_addr:
124 assert(m_unit);
125 m_value.uval = data.GetMaxU64(
126 offset_ptr, m_unit->GetFormParams().getRefAddrByteSize());
127 break;
128 case DW_FORM_indirect:
129 m_form = static_cast<dw_form_t>(data.GetULEB128(offset_ptr));
130 indirect = true;
131 break;
132 case DW_FORM_flag_present:
133 m_value.uval = 1;
134 break;
135 default:
136 return false;
137 }
138 } while (indirect);
139
140 if (is_block) {
141 m_value.data = data.PeekData(*offset_ptr, m_value.uval);
142 if (m_value.data != nullptr) {
143 *offset_ptr += m_value.uval;
144 }
145 }
146
147 return true;
148}
149
150struct FormSize {
151 uint8_t valid:1, size:7;
152};
154 {0, 0}, // 0x00 unused
155 {0, 0}, // 0x01 DW_FORM_addr
156 {0, 0}, // 0x02 unused
157 {0, 0}, // 0x03 DW_FORM_block2
158 {0, 0}, // 0x04 DW_FORM_block4
159 {1, 2}, // 0x05 DW_FORM_data2
160 {1, 4}, // 0x06 DW_FORM_data4
161 {1, 8}, // 0x07 DW_FORM_data8
162 {0, 0}, // 0x08 DW_FORM_string
163 {0, 0}, // 0x09 DW_FORM_block
164 {0, 0}, // 0x0a DW_FORM_block1
165 {1, 1}, // 0x0b DW_FORM_data1
166 {1, 1}, // 0x0c DW_FORM_flag
167 {0, 0}, // 0x0d DW_FORM_sdata
168 {0, 0}, // 0x0e DW_FORM_strp (4 bytes for DWARF32, 8 bytes for DWARF64)
169 {0, 0}, // 0x0f DW_FORM_udata
170 {0, 0}, // 0x10 DW_FORM_ref_addr (addr size for DWARF2 and earlier, 4 bytes
171 // for DWARF32, 8 bytes for DWARF32 in DWARF 3 and later
172 {1, 1}, // 0x11 DW_FORM_ref1
173 {1, 2}, // 0x12 DW_FORM_ref2
174 {1, 4}, // 0x13 DW_FORM_ref4
175 {1, 8}, // 0x14 DW_FORM_ref8
176 {0, 0}, // 0x15 DW_FORM_ref_udata
177 {0, 0}, // 0x16 DW_FORM_indirect
178 {0, 0}, // 0x17 DW_FORM_sec_offset (4 bytes for DWARF32,8 bytes for DWARF64)
179 {0, 0}, // 0x18 DW_FORM_exprloc
180 {1, 0}, // 0x19 DW_FORM_flag_present
181 {0, 0}, // 0x1a DW_FORM_strx (ULEB128)
182 {0, 0}, // 0x1b DW_FORM_addrx (ULEB128)
183 {1, 4}, // 0x1c DW_FORM_ref_sup4
184 {0, 0}, // 0x1d DW_FORM_strp_sup (4 bytes for DWARF32, 8 bytes for DWARF64)
185 {1, 16}, // 0x1e DW_FORM_data16
186 {0, 0}, // 0x1f DW_FORM_line_strp (4 bytes for DWARF32, 8 bytes for DWARF64)
187 {1, 8}, // 0x20 DW_FORM_ref_sig8
188};
189
190std::optional<uint8_t> DWARFFormValue::GetFixedSize(dw_form_t form,
191 const DWARFUnit *u) {
192 if (form <= DW_FORM_ref_sig8 && g_form_sizes[form].valid)
193 return static_cast<uint8_t>(g_form_sizes[form].size);
194 if (form == DW_FORM_addr && u)
195 return u->GetAddressByteSize();
196 return std::nullopt;
197}
198
199std::optional<uint8_t> DWARFFormValue::GetFixedSize() const {
200 return GetFixedSize(m_form, m_unit);
201}
202
204 lldb::offset_t *offset_ptr) const {
205 return DWARFFormValue::SkipValue(m_form, debug_info_data, offset_ptr, m_unit);
206}
207
209 const DWARFDataExtractor &debug_info_data,
210 lldb::offset_t *offset_ptr,
211 const DWARFUnit *unit) {
212 switch (form) {
213 // Blocks if inlined data that have a length field and the data bytes inlined
214 // in the .debug_info
215 case DW_FORM_exprloc:
216 case DW_FORM_block: {
217 uint64_t size = debug_info_data.GetULEB128(offset_ptr);
218 *offset_ptr += size;
219 }
220 return true;
221 case DW_FORM_block1: {
222 uint8_t size = debug_info_data.GetU8(offset_ptr);
223 *offset_ptr += size;
224 }
225 return true;
226 case DW_FORM_block2: {
227 uint16_t size = debug_info_data.GetU16(offset_ptr);
228 *offset_ptr += size;
229 }
230 return true;
231 case DW_FORM_block4: {
232 uint32_t size = debug_info_data.GetU32(offset_ptr);
233 *offset_ptr += size;
234 }
235 return true;
236
237 // Inlined null-terminated C-strings
238 case DW_FORM_string:
239 debug_info_data.GetCStr(offset_ptr);
240 return true;
241
242 // Compile unit address sized values
243 case DW_FORM_addr:
244 *offset_ptr += DWARFUnit::GetAddressByteSize(unit);
245 return true;
246
247 case DW_FORM_ref_addr:
248 assert(unit); // Unit must be valid for DW_FORM_ref_addr objects or we will
249 // get this wrong
250 *offset_ptr += unit->GetFormParams().getRefAddrByteSize();
251 return true;
252
253 // 0 bytes values (implied from DW_FORM)
254 case DW_FORM_flag_present:
255 case DW_FORM_implicit_const:
256 return true;
257
258 // 1 byte values
259 case DW_FORM_addrx1:
260 case DW_FORM_data1:
261 case DW_FORM_flag:
262 case DW_FORM_ref1:
263 case DW_FORM_strx1:
264 *offset_ptr += 1;
265 return true;
266
267 // 2 byte values
268 case DW_FORM_addrx2:
269 case DW_FORM_data2:
270 case DW_FORM_ref2:
271 case DW_FORM_strx2:
272 *offset_ptr += 2;
273 return true;
274
275 // 3 byte values
276 case DW_FORM_addrx3:
277 case DW_FORM_strx3:
278 *offset_ptr += 3;
279 return true;
280
281 // 32 bit for DWARF 32, 64 for DWARF 64
282 case DW_FORM_sec_offset:
283 case DW_FORM_strp:
284 case DW_FORM_line_strp:
285 case DW_FORM_GNU_ref_alt:
286 case DW_FORM_GNU_strp_alt:
287 assert(unit);
288 *offset_ptr += unit->GetFormParams().getDwarfOffsetByteSize();
289 return true;
290
291 // 4 byte values
292 case DW_FORM_addrx4:
293 case DW_FORM_data4:
294 case DW_FORM_ref4:
295 case DW_FORM_strx4:
296 *offset_ptr += 4;
297 return true;
298
299 // 8 byte values
300 case DW_FORM_data8:
301 case DW_FORM_ref8:
302 case DW_FORM_ref_sig8:
303 *offset_ptr += 8;
304 return true;
305
306 // 16 byte values
307 case DW_FORM_data16:
308 *offset_ptr += 16;
309 return true;
310
311 // signed or unsigned LEB 128 values
312 case DW_FORM_addrx:
313 case DW_FORM_loclistx:
314 case DW_FORM_rnglistx:
315 case DW_FORM_sdata:
316 case DW_FORM_udata:
317 case DW_FORM_ref_udata:
318 case DW_FORM_GNU_addr_index:
319 case DW_FORM_GNU_str_index:
320 case DW_FORM_strx:
321 debug_info_data.Skip_LEB128(offset_ptr);
322 return true;
323
324 case DW_FORM_indirect: {
325 auto indirect_form =
326 static_cast<dw_form_t>(debug_info_data.GetULEB128(offset_ptr));
327 return DWARFFormValue::SkipValue(indirect_form, debug_info_data,
328 offset_ptr, unit);
329 }
330
331 default:
332 break;
333 }
334 return false;
335}
336
338 uint64_t uvalue = Unsigned();
339 bool unit_relative_offset = false;
340
341 switch (m_form) {
342 case DW_FORM_addr:
343 DumpAddress(s.AsRawOstream(), uvalue, sizeof(uint64_t));
344 break;
345 case DW_FORM_flag:
346 case DW_FORM_data1:
347 s.PutHex8(uvalue);
348 break;
349 case DW_FORM_data2:
350 s.PutHex16(uvalue);
351 break;
352 case DW_FORM_sec_offset:
353 case DW_FORM_data4:
354 s.PutHex32(uvalue);
355 break;
356 case DW_FORM_ref_sig8:
357 case DW_FORM_data8:
358 s.PutHex64(uvalue);
359 break;
360 case DW_FORM_string:
362 break;
363 case DW_FORM_exprloc:
364 case DW_FORM_block:
365 case DW_FORM_block1:
366 case DW_FORM_block2:
367 case DW_FORM_block4:
368 if (uvalue > 0) {
369 switch (m_form) {
370 case DW_FORM_exprloc:
371 case DW_FORM_block:
372 s.Printf("<0x%" PRIx64 "> ", uvalue);
373 break;
374 case DW_FORM_block1:
375 s.Printf("<0x%2.2x> ", (uint8_t)uvalue);
376 break;
377 case DW_FORM_block2:
378 s.Printf("<0x%4.4x> ", (uint16_t)uvalue);
379 break;
380 case DW_FORM_block4:
381 s.Printf("<0x%8.8x> ", (uint32_t)uvalue);
382 break;
383 default:
384 break;
385 }
386
387 const uint8_t *data_ptr = m_value.data;
388 if (data_ptr) {
389 const uint8_t *end_data_ptr =
390 data_ptr + uvalue; // uvalue contains size of block
391 while (data_ptr < end_data_ptr) {
392 s.Printf("%2.2x ", *data_ptr);
393 ++data_ptr;
394 }
395 } else
396 s.PutCString("NULL");
397 }
398 break;
399
400 case DW_FORM_sdata:
401 s.PutSLEB128(uvalue);
402 break;
403 case DW_FORM_udata:
404 s.PutULEB128(uvalue);
405 break;
406 case DW_FORM_strp:
407 case DW_FORM_line_strp: {
408 const char *dbg_str = AsCString();
409 if (dbg_str) {
410 s.QuotedCString(dbg_str);
411 } else {
412 s.PutHex32(uvalue);
413 }
414 } break;
415
416 case DW_FORM_ref_addr: {
417 assert(m_unit); // Unit must be valid for DW_FORM_ref_addr objects or we
418 // will get this wrong
419 DumpAddress(s.AsRawOstream(), uvalue,
420 m_unit->GetFormParams().getRefAddrByteSize());
421 break;
422 }
423 case DW_FORM_GNU_ref_alt:
424 case DW_FORM_GNU_strp_alt: {
425 assert(m_unit);
426 DumpAddress(s.AsRawOstream(), uvalue,
427 m_unit->GetFormParams().getDwarfOffsetByteSize());
428 break;
429 }
430 case DW_FORM_ref1:
431 unit_relative_offset = true;
432 break;
433 case DW_FORM_ref2:
434 unit_relative_offset = true;
435 break;
436 case DW_FORM_ref4:
437 unit_relative_offset = true;
438 break;
439 case DW_FORM_ref8:
440 unit_relative_offset = true;
441 break;
442 case DW_FORM_ref_udata:
443 unit_relative_offset = true;
444 break;
445
446 // All DW_FORM_indirect attributes should be resolved prior to calling this
447 // function
448 case DW_FORM_indirect:
449 s.PutCString("DW_FORM_indirect");
450 break;
451 case DW_FORM_flag_present:
452 break;
453
454 default:
455 s.Printf("DW_FORM(0x%4.4x)", m_form);
456 break;
457 }
458
459 if (unit_relative_offset) {
460 assert(m_unit); // Unit must be valid for DW_FORM_ref forms that are compile
461 // unit relative or we will get this wrong
462 s.Printf("{0x%8.8" PRIx64 "}", uvalue + m_unit->GetOffset());
463 }
464}
465
466/// PeekCStr only returns strings terminated within the section, so data() is
467/// always a valid C string.
468static const char *PeekCStr(const DWARFDataExtractor &data, uint64_t offset) {
469 if (std::optional<llvm::StringRef> str = data.PeekCStr(offset))
470 return str->data();
471 return nullptr;
472}
473
474const char *DWARFFormValue::AsCString() const {
475 DWARFContext &context = m_unit->GetSymbolFileDWARF().GetDWARFContext();
476
477 if (m_form == DW_FORM_string)
478 return m_value.cstr;
479 if (m_form == DW_FORM_strp)
480 return PeekCStr(context.getOrLoadStrData(), m_value.uval);
481
482 if (m_form == DW_FORM_GNU_str_index || m_form == DW_FORM_strx ||
483 m_form == DW_FORM_strx1 || m_form == DW_FORM_strx2 ||
484 m_form == DW_FORM_strx3 || m_form == DW_FORM_strx4) {
485
486 std::optional<uint64_t> offset =
487 m_unit->GetStringOffsetSectionItem(m_value.uval);
488 if (!offset)
489 return nullptr;
490 return PeekCStr(context.getOrLoadStrData(), *offset);
491 }
492
493 if (m_form == DW_FORM_line_strp)
494 return PeekCStr(context.getOrLoadLineStrData(), m_value.uval);
495
496 return nullptr;
497}
498
500 SymbolFileDWARF &symbol_file = m_unit->GetSymbolFileDWARF();
501
502 if (m_form == DW_FORM_addr)
503 return Unsigned();
504
505 assert(m_unit);
506 assert(m_form == DW_FORM_GNU_addr_index || m_form == DW_FORM_addrx ||
507 m_form == DW_FORM_addrx1 || m_form == DW_FORM_addrx2 ||
508 m_form == DW_FORM_addrx3 || m_form == DW_FORM_addrx4);
509
510 uint32_t index_size = m_unit->GetAddressByteSize();
511 dw_offset_t addr_base = m_unit->GetAddrBase();
512 lldb::offset_t offset = addr_base + m_value.uval * index_size;
513 return symbol_file.GetDWARFContext().getOrLoadAddrData().GetMaxU64(
514 &offset, index_size);
515}
516
517std::pair<DWARFUnit *, uint64_t>
519 uint64_t value = m_value.uval;
520 switch (m_form) {
521 case DW_FORM_ref1:
522 case DW_FORM_ref2:
523 case DW_FORM_ref4:
524 case DW_FORM_ref8:
525 case DW_FORM_ref_udata:
526 assert(m_unit); // Unit must be valid for DW_FORM_ref forms that are compile
527 // unit relative or we will get this wrong
528 value += m_unit->GetOffset();
529 if (!m_unit->ContainsDIEOffset(value)) {
530 m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
531 "DW_FORM_ref* DIE reference {0:x16} is outside of its CU", value);
532 return {nullptr, 0};
533 }
534 return {const_cast<DWARFUnit *>(m_unit), value};
535
536 case DW_FORM_ref_addr: {
537 DWARFUnit *ref_cu =
538 m_unit->GetSymbolFileDWARF().DebugInfo().GetUnitContainingDIEOffset(
540 if (!ref_cu) {
541 m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
542 "DW_FORM_ref_addr DIE reference {0:x16} has no matching CU", value);
543 return {nullptr, 0};
544 }
545 return {ref_cu, value};
546 }
547
548 case DW_FORM_ref_sig8: {
549 DWARFTypeUnit *tu =
550 m_unit->GetSymbolFileDWARF().DebugInfo().GetTypeUnitForHash(value);
551 if (!tu)
552 return {nullptr, 0};
553 return {tu, tu->GetTypeOffset()};
554 }
555
556 default:
557 return {nullptr, 0};
558 }
559}
560
562 auto [unit, offset] = ReferencedUnitAndOffset();
563 return unit ? unit->GetDIE(offset) : DWARFDIE();
564}
565
566uint64_t DWARFFormValue::Reference(dw_offset_t base_offset) const {
567 uint64_t value = m_value.uval;
568 switch (m_form) {
569 case DW_FORM_ref1:
570 case DW_FORM_ref2:
571 case DW_FORM_ref4:
572 case DW_FORM_ref8:
573 case DW_FORM_ref_udata:
574 return value + base_offset;
575
576 case DW_FORM_ref_addr:
577 case DW_FORM_ref_sig8:
578 case DW_FORM_GNU_ref_alt:
579 return value;
580
581 default:
582 return DW_INVALID_OFFSET;
583 }
584}
585
586std::optional<uint64_t> DWARFFormValue::getAsUnsignedConstant() const {
587 if ((!IsDataForm(m_form)) || m_form == llvm::dwarf::DW_FORM_sdata)
588 return std::nullopt;
589 return m_value.uval;
590}
591
592std::optional<int64_t> DWARFFormValue::getAsSignedConstant() const {
593 if ((!IsDataForm(m_form)) ||
594 (m_form == llvm::dwarf::DW_FORM_udata &&
595 uint64_t(std::numeric_limits<int64_t>::max()) < m_value.uval))
596 return std::nullopt;
597 switch (m_form) {
598 case llvm::dwarf::DW_FORM_data4:
599 return int32_t(m_value.uval);
600 case llvm::dwarf::DW_FORM_data2:
601 return int16_t(m_value.uval);
602 case llvm::dwarf::DW_FORM_data1:
603 return int8_t(m_value.uval);
604 case llvm::dwarf::DW_FORM_sdata:
605 case llvm::dwarf::DW_FORM_data8:
606 default:
607 return m_value.sval;
608 }
609}
610
611const uint8_t *DWARFFormValue::BlockData() const { return m_value.data; }
612
614 switch (form) {
615 case DW_FORM_exprloc:
616 case DW_FORM_block:
617 case DW_FORM_block1:
618 case DW_FORM_block2:
619 case DW_FORM_block4:
620 case DW_FORM_data16:
621 return true;
622 default:
623 return false;
624 }
625 llvm_unreachable("All cases handled above!");
626}
627
629 switch (form) {
630 case DW_FORM_sdata:
631 case DW_FORM_udata:
632 case DW_FORM_data1:
633 case DW_FORM_data2:
634 case DW_FORM_data4:
635 case DW_FORM_data8:
636 return true;
637 default:
638 return false;
639 }
640 llvm_unreachable("All cases handled above!");
641}
642
644 switch (form) {
645 case DW_FORM_addr:
646 case DW_FORM_addrx:
647 case DW_FORM_loclistx:
648 case DW_FORM_rnglistx:
649 case DW_FORM_block2:
650 case DW_FORM_block4:
651 case DW_FORM_data2:
652 case DW_FORM_data4:
653 case DW_FORM_data8:
654 case DW_FORM_data16:
655 case DW_FORM_string:
656 case DW_FORM_block:
657 case DW_FORM_block1:
658 case DW_FORM_data1:
659 case DW_FORM_flag:
660 case DW_FORM_sdata:
661 case DW_FORM_strp:
662 case DW_FORM_line_strp:
663 case DW_FORM_strx:
664 case DW_FORM_strx1:
665 case DW_FORM_strx2:
666 case DW_FORM_strx3:
667 case DW_FORM_strx4:
668 case DW_FORM_udata:
669 case DW_FORM_ref_addr:
670 case DW_FORM_ref1:
671 case DW_FORM_ref2:
672 case DW_FORM_ref4:
673 case DW_FORM_ref8:
674 case DW_FORM_ref_udata:
675 case DW_FORM_indirect:
676 case DW_FORM_sec_offset:
677 case DW_FORM_exprloc:
678 case DW_FORM_flag_present:
679 case DW_FORM_ref_sig8:
680 case DW_FORM_GNU_str_index:
681 case DW_FORM_GNU_addr_index:
682 case DW_FORM_implicit_const:
683 case DW_FORM_GNU_ref_alt:
684 case DW_FORM_GNU_strp_alt:
685 return true;
686 default:
687 break;
688 }
689 return false;
690}
static FormSize g_form_sizes[]
static const char * PeekCStr(const DWARFDataExtractor &data, uint64_t offset)
PeekCStr only returns strings terminated within the section, so data() is always a valid C string.
uint64_t GetULEB128(lldb::offset_t *offset_ptr) const
Extract a unsigned LEB128 value from *offset_ptr.
const char * GetCStr(lldb::offset_t *offset_ptr) const
Extract a C string from *offset_ptr.
uint64_t GetU64(lldb::offset_t *offset_ptr) const
Extract a uint64_t value from *offset_ptr.
virtual const uint8_t * PeekData(lldb::offset_t offset, lldb::offset_t length) const
Peek at a bytes at offset.
uint32_t Skip_LEB128(lldb::offset_t *offset_ptr) const
Skip an LEB128 number at *offset_ptr.
uint32_t GetU32(lldb::offset_t *offset_ptr) const
Extract a uint32_t value from *offset_ptr.
uint16_t GetU16(lldb::offset_t *offset_ptr) const
Extract a uint16_t value from *offset_ptr.
uint64_t GetMaxU64(lldb::offset_t *offset_ptr, size_t byte_size) const
Extract an unsigned integer of size byte_size from *offset_ptr.
int64_t GetSLEB128(lldb::offset_t *offset_ptr) const
Extract a signed LEB128 value from *offset_ptr.
std::optional< llvm::StringRef > PeekCStr(lldb::offset_t offset) const
Peek at a null-terminated C string at offset.
uint8_t GetU8(lldb::offset_t *offset_ptr) const
Extract a uint8_t value from *offset_ptr.
A stream class that can stream formatted output to a file.
Definition Stream.h:28
llvm::raw_ostream & AsRawOstream()
Returns a raw_ostream that forwards the data to this Stream object.
Definition Stream.h:405
size_t size_t PutHex8(uint8_t uvalue)
Append an uint8_t value in the hexadecimal format to the stream.
Definition Stream.cpp:269
size_t PutHex64(uint64_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
Definition Stream.cpp:307
size_t Printf(const char *format,...) __attribute__((format(printf
Output printf formatted output to the stream.
Definition Stream.cpp:134
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition Stream.cpp:63
size_t PutHex16(uint16_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
Definition Stream.cpp:275
void QuotedCString(const char *cstr, const char *format="\"%s\"")
Output a quoted C string value to the stream.
Definition Stream.cpp:102
size_t PutHex32(uint32_t uvalue, lldb::ByteOrder byte_order=lldb::eByteOrderInvalid)
Definition Stream.cpp:291
size_t PutULEB128(uint64_t uval)
Output a ULEB128 number to the stream.
Definition Stream.cpp:55
size_t PutSLEB128(int64_t uval)
Output a SLEB128 number to the stream.
Definition Stream.cpp:47
const DWARFDataExtractor & getOrLoadStrData()
const DWARFDataExtractor & getOrLoadLineStrData()
const DWARFDataExtractor & getOrLoadAddrData()
bool ExtractValue(const DWARFDataExtractor &data, lldb::offset_t *offset_ptr)
llvm::DWARFFormValue::ValueType ValueType
static bool IsDataForm(const dw_form_t form)
std::optional< uint8_t > GetFixedSize() const
std::pair< DWARFUnit *, uint64_t > ReferencedUnitAndOffset() const
If this is a reference to another DIE, return the corresponding DWARFUnit and DIE offset such that Un...
bool SkipValue(const DWARFDataExtractor &debug_info_data, lldb::offset_t *offset_ptr) const
std::optional< int64_t > getAsSignedConstant() const
static bool IsBlockForm(const dw_form_t form)
std::optional< uint64_t > getAsUnsignedConstant() const
uint8_t GetAddressByteSize() const override
Definition DWARFUnit.h:127
const llvm::dwarf::FormParams & GetFormParams() const
Definition DWARFUnit.h:122
uint64_t dw_offset_t
Definition dwarf.h:24
#define DW_INVALID_OFFSET
Definition dwarf.h:29
uint64_t dw_addr_t
Definition dwarf.h:20
llvm::dwarf::Form dw_form_t
Definition dwarf.h:18
A class that represents a running process on the host machine.
void DumpAddress(llvm::raw_ostream &s, uint64_t addr, uint32_t addr_size, const char *prefix=nullptr, const char *suffix=nullptr)
Output an address value to this stream.
Definition Stream.cpp:108
uint64_t offset_t
Definition lldb-types.h:86