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
466const char *DWARFFormValue::AsCString() const {
467 DWARFContext &context = m_unit->GetSymbolFileDWARF().GetDWARFContext();
468
469 if (m_form == DW_FORM_string)
470 return m_value.cstr;
471 if (m_form == DW_FORM_strp)
472 return context.getOrLoadStrData().PeekCStr(m_value.uval);
473
474 if (m_form == DW_FORM_GNU_str_index || m_form == DW_FORM_strx ||
475 m_form == DW_FORM_strx1 || m_form == DW_FORM_strx2 ||
476 m_form == DW_FORM_strx3 || m_form == DW_FORM_strx4) {
477
478 std::optional<uint64_t> offset =
479 m_unit->GetStringOffsetSectionItem(m_value.uval);
480 if (!offset)
481 return nullptr;
482 return context.getOrLoadStrData().PeekCStr(*offset);
483 }
484
485 if (m_form == DW_FORM_line_strp)
486 return context.getOrLoadLineStrData().PeekCStr(m_value.uval);
487
488 return nullptr;
489}
490
492 SymbolFileDWARF &symbol_file = m_unit->GetSymbolFileDWARF();
493
494 if (m_form == DW_FORM_addr)
495 return Unsigned();
496
497 assert(m_unit);
498 assert(m_form == DW_FORM_GNU_addr_index || m_form == DW_FORM_addrx ||
499 m_form == DW_FORM_addrx1 || m_form == DW_FORM_addrx2 ||
500 m_form == DW_FORM_addrx3 || m_form == DW_FORM_addrx4);
501
502 uint32_t index_size = m_unit->GetAddressByteSize();
503 dw_offset_t addr_base = m_unit->GetAddrBase();
504 lldb::offset_t offset = addr_base + m_value.uval * index_size;
505 return symbol_file.GetDWARFContext().getOrLoadAddrData().GetMaxU64(
506 &offset, index_size);
507}
508
509std::pair<DWARFUnit *, uint64_t>
511 uint64_t value = m_value.uval;
512 switch (m_form) {
513 case DW_FORM_ref1:
514 case DW_FORM_ref2:
515 case DW_FORM_ref4:
516 case DW_FORM_ref8:
517 case DW_FORM_ref_udata:
518 assert(m_unit); // Unit must be valid for DW_FORM_ref forms that are compile
519 // unit relative or we will get this wrong
520 value += m_unit->GetOffset();
521 if (!m_unit->ContainsDIEOffset(value)) {
522 m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
523 "DW_FORM_ref* DIE reference {0:x16} is outside of its CU", value);
524 return {nullptr, 0};
525 }
526 return {const_cast<DWARFUnit *>(m_unit), value};
527
528 case DW_FORM_ref_addr: {
529 DWARFUnit *ref_cu =
530 m_unit->GetSymbolFileDWARF().DebugInfo().GetUnitContainingDIEOffset(
532 if (!ref_cu) {
533 m_unit->GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
534 "DW_FORM_ref_addr DIE reference {0:x16} has no matching CU", value);
535 return {nullptr, 0};
536 }
537 return {ref_cu, value};
538 }
539
540 case DW_FORM_ref_sig8: {
541 DWARFTypeUnit *tu =
542 m_unit->GetSymbolFileDWARF().DebugInfo().GetTypeUnitForHash(value);
543 if (!tu)
544 return {nullptr, 0};
545 return {tu, tu->GetTypeOffset()};
546 }
547
548 default:
549 return {nullptr, 0};
550 }
551}
552
554 auto [unit, offset] = ReferencedUnitAndOffset();
555 return unit ? unit->GetDIE(offset) : DWARFDIE();
556}
557
558uint64_t DWARFFormValue::Reference(dw_offset_t base_offset) const {
559 uint64_t value = m_value.uval;
560 switch (m_form) {
561 case DW_FORM_ref1:
562 case DW_FORM_ref2:
563 case DW_FORM_ref4:
564 case DW_FORM_ref8:
565 case DW_FORM_ref_udata:
566 return value + base_offset;
567
568 case DW_FORM_ref_addr:
569 case DW_FORM_ref_sig8:
570 case DW_FORM_GNU_ref_alt:
571 return value;
572
573 default:
574 return DW_INVALID_OFFSET;
575 }
576}
577
578std::optional<uint64_t> DWARFFormValue::getAsUnsignedConstant() const {
579 if ((!IsDataForm(m_form)) || m_form == llvm::dwarf::DW_FORM_sdata)
580 return std::nullopt;
581 return m_value.uval;
582}
583
584std::optional<int64_t> DWARFFormValue::getAsSignedConstant() const {
585 if ((!IsDataForm(m_form)) ||
586 (m_form == llvm::dwarf::DW_FORM_udata &&
587 uint64_t(std::numeric_limits<int64_t>::max()) < m_value.uval))
588 return std::nullopt;
589 switch (m_form) {
590 case llvm::dwarf::DW_FORM_data4:
591 return int32_t(m_value.uval);
592 case llvm::dwarf::DW_FORM_data2:
593 return int16_t(m_value.uval);
594 case llvm::dwarf::DW_FORM_data1:
595 return int8_t(m_value.uval);
596 case llvm::dwarf::DW_FORM_sdata:
597 case llvm::dwarf::DW_FORM_data8:
598 default:
599 return m_value.sval;
600 }
601}
602
603const uint8_t *DWARFFormValue::BlockData() const { return m_value.data; }
604
606 switch (form) {
607 case DW_FORM_exprloc:
608 case DW_FORM_block:
609 case DW_FORM_block1:
610 case DW_FORM_block2:
611 case DW_FORM_block4:
612 case DW_FORM_data16:
613 return true;
614 default:
615 return false;
616 }
617 llvm_unreachable("All cases handled above!");
618}
619
621 switch (form) {
622 case DW_FORM_sdata:
623 case DW_FORM_udata:
624 case DW_FORM_data1:
625 case DW_FORM_data2:
626 case DW_FORM_data4:
627 case DW_FORM_data8:
628 return true;
629 default:
630 return false;
631 }
632 llvm_unreachable("All cases handled above!");
633}
634
636 switch (form) {
637 case DW_FORM_addr:
638 case DW_FORM_addrx:
639 case DW_FORM_loclistx:
640 case DW_FORM_rnglistx:
641 case DW_FORM_block2:
642 case DW_FORM_block4:
643 case DW_FORM_data2:
644 case DW_FORM_data4:
645 case DW_FORM_data8:
646 case DW_FORM_data16:
647 case DW_FORM_string:
648 case DW_FORM_block:
649 case DW_FORM_block1:
650 case DW_FORM_data1:
651 case DW_FORM_flag:
652 case DW_FORM_sdata:
653 case DW_FORM_strp:
654 case DW_FORM_line_strp:
655 case DW_FORM_strx:
656 case DW_FORM_strx1:
657 case DW_FORM_strx2:
658 case DW_FORM_strx3:
659 case DW_FORM_strx4:
660 case DW_FORM_udata:
661 case DW_FORM_ref_addr:
662 case DW_FORM_ref1:
663 case DW_FORM_ref2:
664 case DW_FORM_ref4:
665 case DW_FORM_ref8:
666 case DW_FORM_ref_udata:
667 case DW_FORM_indirect:
668 case DW_FORM_sec_offset:
669 case DW_FORM_exprloc:
670 case DW_FORM_flag_present:
671 case DW_FORM_ref_sig8:
672 case DW_FORM_GNU_str_index:
673 case DW_FORM_GNU_addr_index:
674 case DW_FORM_implicit_const:
675 case DW_FORM_GNU_ref_alt:
676 case DW_FORM_GNU_strp_alt:
677 return true;
678 default:
679 break;
680 }
681 return false;
682}
static FormSize g_form_sizes[]
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.
uint8_t GetU8(lldb::offset_t *offset_ptr) const
Extract a uint8_t value from *offset_ptr.
const char * PeekCStr(lldb::offset_t offset) const
Peek at a C string at offset.
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:406
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:65
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:57
size_t PutSLEB128(int64_t uval)
Output a SLEB128 number to the stream.
Definition Stream.cpp:49
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:85