DWARFDebugInfoEntry.cpp revision 296417
1//===-- DWARFDebugInfoEntry.cpp ---------------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#include "DWARFDebugInfoEntry.h"
11
12#include <assert.h>
13
14#include <algorithm>
15
16#include "lldb/Core/Module.h"
17#include "lldb/Core/Stream.h"
18#include "lldb/Expression/DWARFExpression.h"
19#include "lldb/Symbol/ObjectFile.h"
20
21#include "DWARFCompileUnit.h"
22#include "DWARFDebugAbbrev.h"
23#include "DWARFDebugAranges.h"
24#include "DWARFDebugInfo.h"
25#include "DWARFDeclContext.h"
26#include "DWARFDIECollection.h"
27#include "DWARFFormValue.h"
28#include "DWARFDebugRanges.h"
29#include "SymbolFileDWARF.h"
30#include "SymbolFileDWARFDwo.h"
31
32using namespace lldb_private;
33using namespace std;
34extern int g_verbose;
35
36bool
37DWARFDebugInfoEntry::FastExtract
38(
39    const DWARFDataExtractor& debug_info_data,
40    const DWARFCompileUnit* cu,
41    const DWARFFormValue::FixedFormSizes& fixed_form_sizes,
42    lldb::offset_t *offset_ptr
43)
44{
45    m_offset = *offset_ptr;
46    m_parent_idx = 0;
47    m_sibling_idx = 0;
48    m_empty_children = false;
49    const uint64_t abbr_idx = debug_info_data.GetULEB128 (offset_ptr);
50    assert (abbr_idx < (1 << DIE_ABBR_IDX_BITSIZE));
51    m_abbr_idx = abbr_idx;
52
53    //assert (fixed_form_sizes);  // For best performance this should be specified!
54
55    if (m_abbr_idx)
56    {
57        lldb::offset_t offset = *offset_ptr;
58
59        const DWARFAbbreviationDeclaration *abbrevDecl = cu->GetAbbreviations()->GetAbbreviationDeclaration(m_abbr_idx);
60
61        if (abbrevDecl == NULL)
62        {
63            cu->GetSymbolFileDWARF()->GetObjectFile()->GetModule()->ReportError ("{0x%8.8x}: invalid abbreviation code %u, please file a bug and attach the file at the start of this error message",
64                                                                                 m_offset,
65                                                                                 (unsigned)abbr_idx);
66            // WE can't parse anymore if the DWARF is borked...
67            *offset_ptr = UINT32_MAX;
68            return false;
69        }
70        m_tag = abbrevDecl->Tag();
71        m_has_children = abbrevDecl->HasChildren();
72        // Skip all data in the .debug_info for the attributes
73        const uint32_t numAttributes = abbrevDecl->NumAttributes();
74        uint32_t i;
75        dw_form_t form;
76        for (i=0; i<numAttributes; ++i)
77        {
78            form = abbrevDecl->GetFormByIndexUnchecked(i);
79
80            const uint8_t fixed_skip_size = fixed_form_sizes.GetSize(form);
81            if (fixed_skip_size)
82                offset += fixed_skip_size;
83            else
84            {
85                bool form_is_indirect = false;
86                do
87                {
88                    form_is_indirect = false;
89                    uint32_t form_size = 0;
90                    switch (form)
91                    {
92                    // Blocks if inlined data that have a length field and the data bytes
93                    // inlined in the .debug_info
94                    case DW_FORM_exprloc     :
95                    case DW_FORM_block       : form_size = debug_info_data.GetULEB128 (&offset);      break;
96                    case DW_FORM_block1      : form_size = debug_info_data.GetU8_unchecked (&offset); break;
97                    case DW_FORM_block2      : form_size = debug_info_data.GetU16_unchecked (&offset);break;
98                    case DW_FORM_block4      : form_size = debug_info_data.GetU32_unchecked (&offset);break;
99
100                    // Inlined NULL terminated C-strings
101                    case DW_FORM_string      :
102                        debug_info_data.GetCStr (&offset);
103                        break;
104
105                    // Compile unit address sized values
106                    case DW_FORM_addr        :
107                        form_size = cu->GetAddressByteSize();
108                        break;
109                    case DW_FORM_ref_addr    :
110                        if (cu->GetVersion() <= 2)
111                            form_size = cu->GetAddressByteSize();
112                        else
113                            form_size = cu->IsDWARF64() ? 8 : 4;
114                        break;
115
116                    // 0 sized form
117                    case DW_FORM_flag_present:
118                        form_size = 0;
119                        break;
120
121                    // 1 byte values
122                    case DW_FORM_data1       :
123                    case DW_FORM_flag        :
124                    case DW_FORM_ref1        :
125                        form_size = 1;
126                        break;
127
128                    // 2 byte values
129                    case DW_FORM_data2       :
130                    case DW_FORM_ref2        :
131                        form_size = 2;
132                        break;
133
134                    // 4 byte values
135                    case DW_FORM_data4       :
136                    case DW_FORM_ref4        :
137                        form_size = 4;
138                        break;
139
140                    // 8 byte values
141                    case DW_FORM_data8       :
142                    case DW_FORM_ref8        :
143                    case DW_FORM_ref_sig8    :
144                        form_size = 8;
145                        break;
146
147                    // signed or unsigned LEB 128 values
148                    case DW_FORM_sdata         :
149                    case DW_FORM_udata         :
150                    case DW_FORM_ref_udata     :
151                    case DW_FORM_GNU_addr_index:
152                    case DW_FORM_GNU_str_index :
153                        debug_info_data.Skip_LEB128 (&offset);
154                        break;
155
156                    case DW_FORM_indirect    :
157                        form_is_indirect = true;
158                        form = debug_info_data.GetULEB128 (&offset);
159                        break;
160
161                    case DW_FORM_strp        :
162                    case DW_FORM_sec_offset  :
163                        if (cu->IsDWARF64 ())
164                            debug_info_data.GetU64 (offset_ptr);
165                        else
166                            debug_info_data.GetU32 (offset_ptr);
167                        break;
168
169                    default:
170                        *offset_ptr = m_offset;
171                        return false;
172                    }
173                    offset += form_size;
174
175                } while (form_is_indirect);
176            }
177        }
178        *offset_ptr = offset;
179        return true;
180    }
181    else
182    {
183        m_tag = 0;
184        m_has_children = false;
185        return true;    // NULL debug tag entry
186    }
187
188    return false;
189}
190
191//----------------------------------------------------------------------
192// Extract
193//
194// Extract a debug info entry for a given compile unit from the
195// .debug_info and .debug_abbrev data within the SymbolFileDWARF class
196// starting at the given offset
197//----------------------------------------------------------------------
198bool
199DWARFDebugInfoEntry::Extract
200(
201    SymbolFileDWARF* dwarf2Data,
202    const DWARFCompileUnit* cu,
203    lldb::offset_t *offset_ptr
204)
205{
206    const DWARFDataExtractor& debug_info_data = dwarf2Data->get_debug_info_data();
207//    const DWARFDataExtractor& debug_str_data = dwarf2Data->get_debug_str_data();
208    const uint32_t cu_end_offset = cu->GetNextCompileUnitOffset();
209    lldb::offset_t offset = *offset_ptr;
210//  if (offset >= cu_end_offset)
211//      Log::Error("DIE at offset 0x%8.8x is beyond the end of the current compile unit (0x%8.8x)", m_offset, cu_end_offset);
212    if ((offset < cu_end_offset) && debug_info_data.ValidOffset(offset))
213    {
214        m_offset = offset;
215
216        const uint64_t abbr_idx = debug_info_data.GetULEB128(&offset);
217        assert (abbr_idx < (1 << DIE_ABBR_IDX_BITSIZE));
218        m_abbr_idx = abbr_idx;
219        if (abbr_idx)
220        {
221            const DWARFAbbreviationDeclaration *abbrevDecl = cu->GetAbbreviations()->GetAbbreviationDeclaration(abbr_idx);
222
223            if (abbrevDecl)
224            {
225                m_tag = abbrevDecl->Tag();
226                m_has_children = abbrevDecl->HasChildren();
227
228                bool isCompileUnitTag = m_tag == DW_TAG_compile_unit;
229                if (cu && isCompileUnitTag)
230                    const_cast<DWARFCompileUnit *>(cu)->SetBaseAddress(0);
231
232                // Skip all data in the .debug_info for the attributes
233                const uint32_t numAttributes = abbrevDecl->NumAttributes();
234                uint32_t i;
235                dw_attr_t attr;
236                dw_form_t form;
237                for (i=0; i<numAttributes; ++i)
238                {
239                    abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form);
240
241                    if (isCompileUnitTag && ((attr == DW_AT_entry_pc) || (attr == DW_AT_low_pc)))
242                    {
243                        DWARFFormValue form_value(cu, form);
244                        if (form_value.ExtractValue(debug_info_data, &offset))
245                        {
246                            if (attr == DW_AT_low_pc || attr == DW_AT_entry_pc)
247                                const_cast<DWARFCompileUnit*>(cu)->SetBaseAddress(form_value.Address());
248                        }
249                    }
250                    else
251                    {
252                        bool form_is_indirect = false;
253                        do
254                        {
255                            form_is_indirect = false;
256                            uint32_t form_size = 0;
257                            switch (form)
258                            {
259                            // Blocks if inlined data that have a length field and the data bytes
260                            // inlined in the .debug_info
261                            case DW_FORM_exprloc     :
262                            case DW_FORM_block       : form_size = debug_info_data.GetULEB128(&offset);  break;
263                            case DW_FORM_block1      : form_size = debug_info_data.GetU8(&offset);       break;
264                            case DW_FORM_block2      : form_size = debug_info_data.GetU16(&offset);      break;
265                            case DW_FORM_block4      : form_size = debug_info_data.GetU32(&offset);      break;
266
267                            // Inlined NULL terminated C-strings
268                            case DW_FORM_string      : debug_info_data.GetCStr(&offset);                 break;
269
270                            // Compile unit address sized values
271                            case DW_FORM_addr        :
272                                form_size = cu->GetAddressByteSize();
273                                break;
274                            case DW_FORM_ref_addr    :
275                                if (cu->GetVersion() <= 2)
276                                    form_size = cu->GetAddressByteSize();
277                                else
278                                    form_size = cu->IsDWARF64() ? 8 : 4;
279                                break;
280
281                            // 0 sized form
282                            case DW_FORM_flag_present:
283                                form_size = 0;
284                                break;
285
286                            // 1 byte values
287                            case DW_FORM_data1       :
288                            case DW_FORM_flag        :
289                            case DW_FORM_ref1        :
290                                form_size = 1;
291                                break;
292
293                            // 2 byte values
294                            case DW_FORM_data2       :
295                            case DW_FORM_ref2        :
296                                form_size = 2;
297                                break;
298
299                            // 4 byte values
300                            case DW_FORM_data4       :
301                            case DW_FORM_ref4        :
302                                form_size = 4;
303                                break;
304
305                            // 8 byte values
306                            case DW_FORM_data8       :
307                            case DW_FORM_ref8        :
308                            case DW_FORM_ref_sig8    :
309                                form_size = 8;
310                                break;
311
312                            // signed or unsigned LEB 128 values
313                            case DW_FORM_sdata         :
314                            case DW_FORM_udata         :
315                            case DW_FORM_ref_udata     :
316                            case DW_FORM_GNU_addr_index:
317                            case DW_FORM_GNU_str_index :
318                                debug_info_data.Skip_LEB128(&offset);
319                                break;
320
321                            case DW_FORM_indirect    :
322                                form = debug_info_data.GetULEB128(&offset);
323                                form_is_indirect = true;
324                                break;
325
326                            case DW_FORM_strp        :
327                            case DW_FORM_sec_offset  :
328                                if (cu->IsDWARF64 ())
329                                    debug_info_data.GetU64 (offset_ptr);
330                                else
331                                    debug_info_data.GetU32 (offset_ptr);
332                                break;
333
334                            default:
335                                *offset_ptr = offset;
336                                return false;
337                            }
338
339                            offset += form_size;
340                        } while (form_is_indirect);
341                    }
342                }
343                *offset_ptr = offset;
344                return true;
345            }
346        }
347        else
348        {
349            m_tag = 0;
350            m_has_children = false;
351            *offset_ptr = offset;
352            return true;    // NULL debug tag entry
353        }
354    }
355
356    return false;
357}
358
359//----------------------------------------------------------------------
360// DumpAncestry
361//
362// Dumps all of a debug information entries parents up until oldest and
363// all of it's attributes to the specified stream.
364//----------------------------------------------------------------------
365void
366DWARFDebugInfoEntry::DumpAncestry
367(
368    SymbolFileDWARF* dwarf2Data,
369    const DWARFCompileUnit* cu,
370    const DWARFDebugInfoEntry* oldest,
371    Stream &s,
372    uint32_t recurse_depth
373) const
374{
375    const DWARFDebugInfoEntry* parent = GetParent();
376    if (parent && parent != oldest)
377        parent->DumpAncestry(dwarf2Data, cu, oldest, s, 0);
378    Dump(dwarf2Data, cu, s, recurse_depth);
379}
380
381//----------------------------------------------------------------------
382// GetDIENamesAndRanges
383//
384// Gets the valid address ranges for a given DIE by looking for a
385// DW_AT_low_pc/DW_AT_high_pc pair, DW_AT_entry_pc, or DW_AT_ranges
386// attributes.
387//----------------------------------------------------------------------
388bool
389DWARFDebugInfoEntry::GetDIENamesAndRanges
390(
391    SymbolFileDWARF* dwarf2Data,
392    const DWARFCompileUnit* cu,
393    const char * &name,
394    const char * &mangled,
395    DWARFRangeList& ranges,
396    int& decl_file,
397    int& decl_line,
398    int& decl_column,
399    int& call_file,
400    int& call_line,
401    int& call_column,
402    DWARFExpression *frame_base
403) const
404{
405    if (dwarf2Data == nullptr)
406        return false;
407
408    SymbolFileDWARFDwo* dwo_symbol_file = cu->GetDwoSymbolFile();
409    if (dwo_symbol_file)
410        return GetDIENamesAndRanges(dwo_symbol_file,
411                                    dwo_symbol_file->GetCompileUnit(),
412                                    name,
413                                    mangled,
414                                    ranges,
415                                    decl_file,
416                                    decl_line,
417                                    decl_column,
418                                    call_file,
419                                    call_line,
420                                    call_column,
421                                    frame_base);
422
423    dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
424    dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
425    std::vector<DIERef> die_refs;
426    bool set_frame_base_loclist_addr = false;
427
428    lldb::offset_t offset;
429    const DWARFAbbreviationDeclaration* abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
430
431    lldb::ModuleSP module = dwarf2Data->GetObjectFile()->GetModule();
432
433    if (abbrevDecl)
434    {
435        const DWARFDataExtractor& debug_info_data = dwarf2Data->get_debug_info_data();
436
437        if (!debug_info_data.ValidOffset(offset))
438            return false;
439
440        const uint32_t numAttributes = abbrevDecl->NumAttributes();
441        uint32_t i;
442        dw_attr_t attr;
443        dw_form_t form;
444        bool do_offset = false;
445
446        for (i=0; i<numAttributes; ++i)
447        {
448            abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form);
449            DWARFFormValue form_value(cu, form);
450            if (form_value.ExtractValue(debug_info_data, &offset))
451            {
452                switch (attr)
453                {
454                case DW_AT_low_pc:
455                    lo_pc = form_value.Address();
456
457                    if (do_offset)
458                        hi_pc += lo_pc;
459                    do_offset = false;
460                    break;
461
462                case DW_AT_entry_pc:
463                    lo_pc = form_value.Address();
464                    break;
465
466                case DW_AT_high_pc:
467                    if (form_value.Form() == DW_FORM_addr ||
468                        form_value.Form() == DW_FORM_GNU_addr_index)
469                    {
470                        hi_pc = form_value.Address();
471                    }
472                    else
473                    {
474                        hi_pc = form_value.Unsigned();
475                        if (lo_pc == LLDB_INVALID_ADDRESS)
476                            do_offset = hi_pc != LLDB_INVALID_ADDRESS;
477                        else
478                            hi_pc += lo_pc; // DWARF 4 introduces <offset-from-lo-pc> to save on relocations
479                    }
480                    break;
481
482                case DW_AT_ranges:
483                    {
484                        const DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges();
485                        debug_ranges->FindRanges(form_value.Unsigned(), ranges);
486                        // All DW_AT_ranges are relative to the base address of the
487                        // compile unit. We add the compile unit base address to make
488                        // sure all the addresses are properly fixed up.
489                        ranges.Slide(cu->GetBaseAddress());
490                    }
491                    break;
492
493                case DW_AT_name:
494                    if (name == NULL)
495                        name = form_value.AsCString();
496                    break;
497
498                case DW_AT_MIPS_linkage_name:
499                case DW_AT_linkage_name:
500                    if (mangled == NULL)
501                        mangled = form_value.AsCString();
502                    break;
503
504                case DW_AT_abstract_origin:
505                    die_refs.emplace_back(form_value);
506                    break;
507
508                case DW_AT_specification:
509                    die_refs.emplace_back(form_value);
510                    break;
511
512                case DW_AT_decl_file:
513                    if (decl_file == 0)
514                        decl_file = form_value.Unsigned();
515                    break;
516
517                case DW_AT_decl_line:
518                    if (decl_line == 0)
519                        decl_line = form_value.Unsigned();
520                    break;
521
522                case DW_AT_decl_column:
523                    if (decl_column == 0)
524                        decl_column = form_value.Unsigned();
525                    break;
526
527                case DW_AT_call_file:
528                    if (call_file == 0)
529                        call_file = form_value.Unsigned();
530                    break;
531
532                case DW_AT_call_line:
533                    if (call_line == 0)
534                        call_line = form_value.Unsigned();
535                    break;
536
537                case DW_AT_call_column:
538                    if (call_column == 0)
539                        call_column = form_value.Unsigned();
540                    break;
541
542                case DW_AT_frame_base:
543                    if (frame_base)
544                    {
545                        if (form_value.BlockData())
546                        {
547                            uint32_t block_offset = form_value.BlockData() - debug_info_data.GetDataStart();
548                            uint32_t block_length = form_value.Unsigned();
549                            frame_base->SetOpcodeData(module, debug_info_data, block_offset, block_length);
550                        }
551                        else
552                        {
553                            const DWARFDataExtractor &debug_loc_data = dwarf2Data->get_debug_loc_data();
554                            const dw_offset_t debug_loc_offset = form_value.Unsigned();
555
556                            size_t loc_list_length = DWARFExpression::LocationListSize(cu, debug_loc_data, debug_loc_offset);
557                            if (loc_list_length > 0)
558                            {
559                                frame_base->SetOpcodeData(module, debug_loc_data, debug_loc_offset, loc_list_length);
560                                if (lo_pc != LLDB_INVALID_ADDRESS)
561                                {
562                                    assert (lo_pc >= cu->GetBaseAddress());
563                                    frame_base->SetLocationListSlide(lo_pc - cu->GetBaseAddress());
564                                }
565                                else
566                                {
567                                    set_frame_base_loclist_addr = true;
568                                }
569                            }
570                        }
571                    }
572                    break;
573
574                default:
575                    break;
576                }
577            }
578        }
579    }
580
581    if (ranges.IsEmpty())
582    {
583        if (lo_pc != LLDB_INVALID_ADDRESS)
584        {
585            if (hi_pc != LLDB_INVALID_ADDRESS && hi_pc > lo_pc)
586                ranges.Append(DWARFRangeList::Entry (lo_pc, hi_pc - lo_pc));
587            else
588                ranges.Append(DWARFRangeList::Entry (lo_pc, 0));
589        }
590    }
591
592    if (set_frame_base_loclist_addr)
593    {
594        dw_addr_t lowest_range_pc = ranges.GetMinRangeBase(0);
595        assert (lowest_range_pc >= cu->GetBaseAddress());
596        frame_base->SetLocationListSlide (lowest_range_pc - cu->GetBaseAddress());
597    }
598
599    if (ranges.IsEmpty() || name == NULL || mangled == NULL)
600    {
601        for (const DIERef& die_ref : die_refs)
602        {
603            if (die_ref.die_offset != DW_INVALID_OFFSET)
604            {
605                DWARFDIE die = dwarf2Data->DebugInfo()->GetDIE(die_ref);
606                if (die)
607                    die.GetDIE()->GetDIENamesAndRanges(die.GetDWARF(), die.GetCU(), name, mangled, ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column);
608            }
609        }
610    }
611    return !ranges.IsEmpty();
612}
613
614//----------------------------------------------------------------------
615// Dump
616//
617// Dumps a debug information entry and all of it's attributes to the
618// specified stream.
619//----------------------------------------------------------------------
620void
621DWARFDebugInfoEntry::Dump
622(
623    SymbolFileDWARF* dwarf2Data,
624    const DWARFCompileUnit* cu,
625    Stream &s,
626    uint32_t recurse_depth
627) const
628{
629    const DWARFDataExtractor& debug_info_data = dwarf2Data->get_debug_info_data();
630    lldb::offset_t offset = m_offset;
631
632    if (debug_info_data.ValidOffset(offset))
633    {
634        dw_uleb128_t abbrCode = debug_info_data.GetULEB128(&offset);
635
636        s.Printf("\n0x%8.8x: ", m_offset);
637        s.Indent();
638        if (abbrCode != m_abbr_idx)
639        {
640            s.Printf( "error: DWARF has been modified\n");
641        }
642        else if (abbrCode)
643        {
644            const DWARFAbbreviationDeclaration* abbrevDecl = cu->GetAbbreviations()->GetAbbreviationDeclaration (abbrCode);
645
646            if (abbrevDecl)
647            {
648                s.PutCString(DW_TAG_value_to_name(abbrevDecl->Tag()));
649                s.Printf( " [%u] %c\n", abbrCode, abbrevDecl->HasChildren() ? '*':' ');
650
651                // Dump all data in the .debug_info for the attributes
652                const uint32_t numAttributes = abbrevDecl->NumAttributes();
653                uint32_t i;
654                dw_attr_t attr;
655                dw_form_t form;
656                for (i=0; i<numAttributes; ++i)
657                {
658                    abbrevDecl->GetAttrAndFormByIndexUnchecked(i, attr, form);
659
660                    DumpAttribute(dwarf2Data, cu, debug_info_data, &offset, s, attr, form);
661                }
662
663                const DWARFDebugInfoEntry* child = GetFirstChild();
664                if (recurse_depth > 0 && child)
665                {
666                    s.IndentMore();
667
668                    while (child)
669                    {
670                        child->Dump(dwarf2Data, cu, s, recurse_depth-1);
671                        child = child->GetSibling();
672                    }
673                    s.IndentLess();
674                }
675            }
676            else
677                s.Printf( "Abbreviation code note found in 'debug_abbrev' class for code: %u\n", abbrCode);
678        }
679        else
680        {
681            s.Printf( "NULL\n");
682        }
683    }
684}
685
686void
687DWARFDebugInfoEntry::DumpLocation
688(
689    SymbolFileDWARF* dwarf2Data,
690    DWARFCompileUnit* cu,
691    Stream &s
692) const
693{
694    const DWARFDIE cu_die = cu->GetCompileUnitDIEOnly();
695    const char *cu_name = NULL;
696    if (cu_die)
697        cu_name = cu_die.GetName ();
698    const char *obj_file_name = NULL;
699    ObjectFile *obj_file = dwarf2Data->GetObjectFile();
700    if (obj_file)
701        obj_file_name = obj_file->GetFileSpec().GetFilename().AsCString("<Unknown>");
702    const char *die_name = GetName (dwarf2Data, cu);
703    s.Printf ("0x%8.8x/0x%8.8x: %-30s (from %s in %s)",
704              cu->GetOffset(),
705              GetOffset(),
706              die_name ? die_name : "",
707              cu_name ? cu_name : "<NULL>",
708              obj_file_name ? obj_file_name : "<NULL>");
709}
710
711//----------------------------------------------------------------------
712// DumpAttribute
713//
714// Dumps a debug information entry attribute along with it's form. Any
715// special display of attributes is done (disassemble location lists,
716// show enumeration values for attributes, etc).
717//----------------------------------------------------------------------
718void
719DWARFDebugInfoEntry::DumpAttribute
720(
721    SymbolFileDWARF* dwarf2Data,
722    const DWARFCompileUnit* cu,
723    const DWARFDataExtractor& debug_info_data,
724    lldb::offset_t *offset_ptr,
725    Stream &s,
726    dw_attr_t attr,
727    dw_form_t form
728)
729{
730    bool verbose    = s.GetVerbose();
731    bool show_form  = s.GetFlags().Test(DWARFDebugInfo::eDumpFlag_ShowForm);
732
733    if (verbose)
734        s.Offset (*offset_ptr);
735    else
736        s.Printf ("            ");
737    s.Indent(DW_AT_value_to_name(attr));
738
739    if (show_form)
740    {
741        s.Printf( "[%s", DW_FORM_value_to_name(form));
742    }
743
744    DWARFFormValue form_value(cu, form);
745
746    if (!form_value.ExtractValue(debug_info_data, offset_ptr))
747        return;
748
749    if (show_form)
750    {
751        if (form == DW_FORM_indirect)
752        {
753            s.Printf( " [%s]", DW_FORM_value_to_name(form_value.Form()));
754        }
755
756        s.PutCString("] ");
757    }
758
759    s.PutCString("( ");
760
761    // Always dump form value if verbose is enabled
762    if (verbose)
763    {
764        form_value.Dump(s);
765    }
766
767
768    // Check to see if we have any special attribute formatters
769    switch (attr)
770    {
771    case DW_AT_stmt_list:
772        if ( verbose ) s.PutCString(" ( ");
773        s.Printf( "0x%8.8" PRIx64, form_value.Unsigned());
774        if ( verbose ) s.PutCString(" )");
775        break;
776
777    case DW_AT_language:
778        if ( verbose ) s.PutCString(" ( ");
779        s.PutCString(DW_LANG_value_to_name(form_value.Unsigned()));
780        if ( verbose ) s.PutCString(" )");
781        break;
782
783    case DW_AT_encoding:
784        if ( verbose ) s.PutCString(" ( ");
785        s.PutCString(DW_ATE_value_to_name(form_value.Unsigned()));
786        if ( verbose ) s.PutCString(" )");
787        break;
788
789    case DW_AT_frame_base:
790    case DW_AT_location:
791    case DW_AT_data_member_location:
792        {
793            const uint8_t* blockData = form_value.BlockData();
794            if (blockData)
795            {
796                if (!verbose)
797                    form_value.Dump(s);
798
799                // Location description is inlined in data in the form value
800                DWARFDataExtractor locationData(debug_info_data, (*offset_ptr) - form_value.Unsigned(), form_value.Unsigned());
801                if ( verbose ) s.PutCString(" ( ");
802                DWARFExpression::PrintDWARFExpression(s,
803                                                      locationData,
804                                                      DWARFCompileUnit::GetAddressByteSize(cu),
805                                                      4,
806                                                      false);
807                if ( verbose ) s.PutCString(" )");
808            }
809            else
810            {
811                // We have a location list offset as the value that is
812                // the offset into the .debug_loc section that describes
813                // the value over it's lifetime
814                uint64_t debug_loc_offset = form_value.Unsigned();
815                if (dwarf2Data)
816                {
817                    if ( !verbose )
818                        form_value.Dump(s);
819                    DWARFExpression::PrintDWARFLocationList(s,
820                                                            cu,
821                                                            dwarf2Data->get_debug_loc_data(),
822                                                            debug_loc_offset);
823                }
824                else
825                {
826                    if ( !verbose )
827                        form_value.Dump(s);
828                }
829            }
830        }
831        break;
832
833    case DW_AT_abstract_origin:
834    case DW_AT_specification:
835        {
836            uint64_t abstract_die_offset = form_value.Reference();
837            form_value.Dump(s);
838        //  *ostrm_ptr << HEX32 << abstract_die_offset << " ( ";
839            if ( verbose ) s.PutCString(" ( ");
840            GetName(dwarf2Data, cu, abstract_die_offset, s);
841            if ( verbose ) s.PutCString(" )");
842        }
843        break;
844
845    case DW_AT_type:
846        {
847            uint64_t type_die_offset = form_value.Reference();
848            if (!verbose)
849                form_value.Dump(s);
850            s.PutCString(" ( ");
851            AppendTypeName(dwarf2Data, cu, type_die_offset, s);
852            s.PutCString(" )");
853        }
854        break;
855
856    case DW_AT_ranges:
857        {
858            if ( !verbose )
859                form_value.Dump(s);
860            lldb::offset_t ranges_offset = form_value.Unsigned();
861            dw_addr_t base_addr = cu ? cu->GetBaseAddress() : 0;
862            if (dwarf2Data)
863                DWARFDebugRanges::Dump(s, dwarf2Data->get_debug_ranges_data(), &ranges_offset, base_addr);
864        }
865        break;
866
867    default:
868        if ( !verbose )
869            form_value.Dump(s);
870        break;
871    }
872
873    s.PutCString(" )\n");
874}
875
876//----------------------------------------------------------------------
877// Get all attribute values for a given DIE, including following any
878// specification or abstract origin attributes and including those in
879// the results. Any duplicate attributes will have the first instance
880// take precedence (this can happen for declaration attributes).
881//----------------------------------------------------------------------
882size_t
883DWARFDebugInfoEntry::GetAttributes (const DWARFCompileUnit* cu,
884                                    DWARFFormValue::FixedFormSizes fixed_form_sizes,
885                                    DWARFAttributes& attributes,
886                                    uint32_t curr_depth) const
887{
888    SymbolFileDWARF* dwarf2Data = nullptr;
889    const DWARFAbbreviationDeclaration* abbrevDecl = nullptr;
890    lldb::offset_t offset = 0;
891    if (cu)
892    {
893        if (m_tag != DW_TAG_compile_unit)
894        {
895            SymbolFileDWARFDwo* dwo_symbol_file = cu->GetDwoSymbolFile();
896            if (dwo_symbol_file)
897                return GetAttributes(dwo_symbol_file->GetCompileUnit(),
898                                     fixed_form_sizes,
899                                     attributes,
900                                     curr_depth);
901        }
902
903        dwarf2Data = cu->GetSymbolFileDWARF();
904        abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
905    }
906
907    if (abbrevDecl)
908    {
909        const DWARFDataExtractor& debug_info_data = dwarf2Data->get_debug_info_data();
910
911        if (fixed_form_sizes.Empty())
912            fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize(
913                    cu->GetAddressByteSize(), cu->IsDWARF64());
914
915        const uint32_t num_attributes = abbrevDecl->NumAttributes();
916        uint32_t i;
917        dw_attr_t attr;
918        dw_form_t form;
919        for (i=0; i<num_attributes; ++i)
920        {
921            abbrevDecl->GetAttrAndFormByIndexUnchecked (i, attr, form);
922
923            // If we are tracking down DW_AT_specification or DW_AT_abstract_origin
924            // attributes, the depth will be non-zero. We need to omit certain
925            // attributes that don't make sense.
926            switch (attr)
927            {
928            case DW_AT_sibling:
929            case DW_AT_declaration:
930                if (curr_depth > 0)
931                {
932                    // This attribute doesn't make sense when combined with
933                    // the DIE that references this DIE. We know a DIE is
934                    // referencing this DIE because curr_depth is not zero
935                    break;
936                }
937                // Fall through...
938            default:
939                attributes.Append(cu, offset, attr, form);
940                break;
941            }
942
943            if ((attr == DW_AT_specification) || (attr == DW_AT_abstract_origin))
944            {
945                DWARFFormValue form_value (cu, form);
946                if (form_value.ExtractValue(debug_info_data, &offset))
947                {
948                    dw_offset_t die_offset = form_value.Reference();
949                    DWARFDIE spec_die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(die_offset);
950                    if (spec_die)
951                        spec_die.GetAttributes(attributes, curr_depth + 1);
952                }
953            }
954            else
955            {
956                const uint8_t fixed_skip_size = fixed_form_sizes.GetSize(form);
957                if (fixed_skip_size)
958                    offset += fixed_skip_size;
959                else
960                    DWARFFormValue::SkipValue(form, debug_info_data, &offset, cu);
961            }
962        }
963    }
964    else
965    {
966        attributes.Clear();
967    }
968    return attributes.Size();
969
970}
971
972//----------------------------------------------------------------------
973// GetAttributeValue
974//
975// Get the value of an attribute and return the .debug_info offset of the
976// attribute if it was properly extracted into form_value, or zero
977// if we fail since an offset of zero is invalid for an attribute (it
978// would be a compile unit header).
979//----------------------------------------------------------------------
980dw_offset_t
981DWARFDebugInfoEntry::GetAttributeValue
982(
983    SymbolFileDWARF* dwarf2Data,
984    const DWARFCompileUnit* cu,
985    const dw_attr_t attr,
986    DWARFFormValue& form_value,
987    dw_offset_t* end_attr_offset_ptr,
988    bool check_specification_or_abstract_origin
989) const
990{
991    SymbolFileDWARFDwo* dwo_symbol_file = cu->GetDwoSymbolFile();
992    if (dwo_symbol_file && m_tag != DW_TAG_compile_unit)
993        return GetAttributeValue(dwo_symbol_file,
994                                 dwo_symbol_file->GetCompileUnit(),
995                                 attr,
996                                 form_value,
997                                 end_attr_offset_ptr,
998                                 check_specification_or_abstract_origin);
999
1000    lldb::offset_t offset;
1001    const DWARFAbbreviationDeclaration* abbrevDecl = GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
1002
1003    if (abbrevDecl)
1004    {
1005        uint32_t attr_idx = abbrevDecl->FindAttributeIndex(attr);
1006
1007        if (attr_idx != DW_INVALID_INDEX)
1008        {
1009            const DWARFDataExtractor& debug_info_data = dwarf2Data->get_debug_info_data();
1010
1011            uint32_t idx=0;
1012            while (idx<attr_idx)
1013                DWARFFormValue::SkipValue(abbrevDecl->GetFormByIndex(idx++), debug_info_data, &offset, cu);
1014
1015            const dw_offset_t attr_offset = offset;
1016            form_value.SetCompileUnit(cu);
1017            form_value.SetForm(abbrevDecl->GetFormByIndex(idx));
1018            if (form_value.ExtractValue(debug_info_data, &offset))
1019            {
1020                if (end_attr_offset_ptr)
1021                    *end_attr_offset_ptr = offset;
1022                return attr_offset;
1023            }
1024        }
1025    }
1026
1027    if (check_specification_or_abstract_origin)
1028    {
1029        if (GetAttributeValue(dwarf2Data, cu, DW_AT_specification, form_value))
1030        {
1031            DWARFDIE die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(form_value.Reference());
1032            if (die)
1033            {
1034                dw_offset_t die_offset = die.GetDIE()->GetAttributeValue(die.GetDWARF(),
1035                                                                         die.GetCU(),
1036                                                                         attr,
1037                                                                         form_value,
1038                                                                         end_attr_offset_ptr,
1039                                                                         false);
1040                if (die_offset)
1041                    return die_offset;
1042            }
1043        }
1044
1045        if (GetAttributeValue(dwarf2Data, cu, DW_AT_abstract_origin, form_value))
1046        {
1047            DWARFDIE die = const_cast<DWARFCompileUnit*>(cu)->GetDIE(form_value.Reference());
1048            if (die)
1049            {
1050                dw_offset_t die_offset = die.GetDIE()->GetAttributeValue(die.GetDWARF(),
1051                                                                         die.GetCU(),
1052                                                                         attr,
1053                                                                         form_value,
1054                                                                         end_attr_offset_ptr,
1055                                                                         false);
1056                if (die_offset)
1057                    return die_offset;
1058            }
1059        }
1060    }
1061
1062    if (!dwo_symbol_file)
1063        return 0;
1064
1065    DWARFCompileUnit* dwo_cu = dwo_symbol_file->GetCompileUnit();
1066    if (!dwo_cu)
1067        return 0;
1068
1069    DWARFDIE dwo_cu_die = dwo_cu->GetCompileUnitDIEOnly();
1070    if (!dwo_cu_die.IsValid())
1071        return 0;
1072
1073    return dwo_cu_die.GetDIE()->GetAttributeValue(dwo_symbol_file,
1074                                                  dwo_cu,
1075                                                  attr,
1076                                                  form_value,
1077                                                  end_attr_offset_ptr,
1078                                                  check_specification_or_abstract_origin);
1079}
1080
1081//----------------------------------------------------------------------
1082// GetAttributeValueAsString
1083//
1084// Get the value of an attribute as a string return it. The resulting
1085// pointer to the string data exists within the supplied SymbolFileDWARF
1086// and will only be available as long as the SymbolFileDWARF is still around
1087// and it's content doesn't change.
1088//----------------------------------------------------------------------
1089const char*
1090DWARFDebugInfoEntry::GetAttributeValueAsString
1091(
1092    SymbolFileDWARF* dwarf2Data,
1093    const DWARFCompileUnit* cu,
1094    const dw_attr_t attr,
1095    const char* fail_value,
1096    bool check_specification_or_abstract_origin) const
1097{
1098    DWARFFormValue form_value;
1099    if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
1100        return form_value.AsCString();
1101    return fail_value;
1102}
1103
1104//----------------------------------------------------------------------
1105// GetAttributeValueAsUnsigned
1106//
1107// Get the value of an attribute as unsigned and return it.
1108//----------------------------------------------------------------------
1109uint64_t
1110DWARFDebugInfoEntry::GetAttributeValueAsUnsigned
1111(
1112    SymbolFileDWARF* dwarf2Data,
1113    const DWARFCompileUnit* cu,
1114    const dw_attr_t attr,
1115    uint64_t fail_value,
1116    bool check_specification_or_abstract_origin
1117) const
1118{
1119    DWARFFormValue form_value;
1120    if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
1121        return form_value.Unsigned();
1122    return fail_value;
1123}
1124
1125//----------------------------------------------------------------------
1126// GetAttributeValueAsSigned
1127//
1128// Get the value of an attribute a signed value and return it.
1129//----------------------------------------------------------------------
1130int64_t
1131DWARFDebugInfoEntry::GetAttributeValueAsSigned
1132(
1133    SymbolFileDWARF* dwarf2Data,
1134    const DWARFCompileUnit* cu,
1135    const dw_attr_t attr,
1136    int64_t fail_value,
1137    bool check_specification_or_abstract_origin
1138) const
1139{
1140    DWARFFormValue form_value;
1141    if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
1142        return form_value.Signed();
1143    return fail_value;
1144}
1145
1146//----------------------------------------------------------------------
1147// GetAttributeValueAsReference
1148//
1149// Get the value of an attribute as reference and fix up and compile
1150// unit relative offsets as needed.
1151//----------------------------------------------------------------------
1152uint64_t
1153DWARFDebugInfoEntry::GetAttributeValueAsReference
1154(
1155    SymbolFileDWARF* dwarf2Data,
1156    const DWARFCompileUnit* cu,
1157    const dw_attr_t attr,
1158    uint64_t fail_value,
1159    bool check_specification_or_abstract_origin
1160) const
1161{
1162    DWARFFormValue form_value;
1163    if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
1164        return form_value.Reference();
1165    return fail_value;
1166}
1167
1168uint64_t
1169DWARFDebugInfoEntry::GetAttributeValueAsAddress
1170(
1171    SymbolFileDWARF* dwarf2Data,
1172    const DWARFCompileUnit* cu,
1173    const dw_attr_t attr,
1174    uint64_t fail_value,
1175    bool check_specification_or_abstract_origin
1176) const
1177{
1178    DWARFFormValue form_value;
1179    if (GetAttributeValue(dwarf2Data, cu, attr, form_value, nullptr, check_specification_or_abstract_origin))
1180        return form_value.Address();
1181    return fail_value;
1182}
1183
1184//----------------------------------------------------------------------
1185// GetAttributeHighPC
1186//
1187// Get the hi_pc, adding hi_pc to lo_pc when specified
1188// as an <offset-from-low-pc>.
1189//
1190// Returns the hi_pc or fail_value.
1191//----------------------------------------------------------------------
1192dw_addr_t
1193DWARFDebugInfoEntry::GetAttributeHighPC
1194(
1195    SymbolFileDWARF* dwarf2Data,
1196    const DWARFCompileUnit* cu,
1197    dw_addr_t lo_pc,
1198    uint64_t fail_value,
1199    bool check_specification_or_abstract_origin
1200) const
1201{
1202    DWARFFormValue form_value;
1203    if (GetAttributeValue(dwarf2Data, cu, DW_AT_high_pc, form_value, nullptr, check_specification_or_abstract_origin))
1204    {
1205        dw_form_t form = form_value.Form();
1206        if (form == DW_FORM_addr || form == DW_FORM_GNU_addr_index)
1207            return form_value.Address();
1208
1209        // DWARF4 can specify the hi_pc as an <offset-from-lowpc>
1210        return lo_pc + form_value.Unsigned();
1211    }
1212    return fail_value;
1213}
1214
1215//----------------------------------------------------------------------
1216// GetAttributeAddressRange
1217//
1218// Get the lo_pc and hi_pc, adding hi_pc to lo_pc when specified
1219// as an <offset-from-low-pc>.
1220//
1221// Returns true or sets lo_pc and hi_pc to fail_value.
1222//----------------------------------------------------------------------
1223bool
1224DWARFDebugInfoEntry::GetAttributeAddressRange
1225(
1226    SymbolFileDWARF* dwarf2Data,
1227    const DWARFCompileUnit* cu,
1228    dw_addr_t& lo_pc,
1229    dw_addr_t& hi_pc,
1230    uint64_t fail_value,
1231    bool check_specification_or_abstract_origin
1232) const
1233{
1234    lo_pc = GetAttributeValueAsAddress(dwarf2Data, cu, DW_AT_low_pc, fail_value, check_specification_or_abstract_origin);
1235    if (lo_pc != fail_value)
1236    {
1237        hi_pc = GetAttributeHighPC(dwarf2Data, cu, lo_pc, fail_value, check_specification_or_abstract_origin);
1238        if (hi_pc != fail_value)
1239          return true;
1240    }
1241    lo_pc = fail_value;
1242    hi_pc = fail_value;
1243    return false;
1244}
1245
1246size_t
1247DWARFDebugInfoEntry::GetAttributeAddressRanges (SymbolFileDWARF* dwarf2Data,
1248                                                const DWARFCompileUnit* cu,
1249                                                DWARFRangeList &ranges,
1250                                                bool check_hi_lo_pc,
1251                                                bool check_specification_or_abstract_origin) const
1252{
1253    ranges.Clear();
1254
1255    dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data,
1256                                                                  cu,
1257                                                                  DW_AT_ranges,
1258                                                                  DW_INVALID_OFFSET,
1259                                                                  check_specification_or_abstract_origin);
1260    if (debug_ranges_offset != DW_INVALID_OFFSET)
1261    {
1262        DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges();
1263
1264        debug_ranges->FindRanges(debug_ranges_offset, ranges);
1265        ranges.Slide (cu->GetBaseAddress());
1266    }
1267    else if (check_hi_lo_pc)
1268    {
1269        dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
1270        dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
1271        if (GetAttributeAddressRange (dwarf2Data, cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS, check_specification_or_abstract_origin))
1272        {
1273            if (lo_pc < hi_pc)
1274                ranges.Append(DWARFRangeList::Entry(lo_pc, hi_pc - lo_pc));
1275        }
1276    }
1277    return ranges.GetSize();
1278}
1279
1280//----------------------------------------------------------------------
1281// GetName
1282//
1283// Get value of the DW_AT_name attribute and return it if one exists,
1284// else return NULL.
1285//----------------------------------------------------------------------
1286const char*
1287DWARFDebugInfoEntry::GetName
1288(
1289    SymbolFileDWARF* dwarf2Data,
1290    const DWARFCompileUnit* cu
1291) const
1292{
1293    return GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
1294}
1295
1296//----------------------------------------------------------------------
1297// GetMangledName
1298//
1299// Get value of the DW_AT_MIPS_linkage_name attribute and return it if
1300// one exists, else return the value of the DW_AT_name attribute
1301//----------------------------------------------------------------------
1302const char*
1303DWARFDebugInfoEntry::GetMangledName
1304(
1305    SymbolFileDWARF* dwarf2Data,
1306    const DWARFCompileUnit* cu,
1307    bool substitute_name_allowed
1308) const
1309{
1310    const char* name = nullptr;
1311
1312    name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_MIPS_linkage_name, nullptr, true);
1313    if (name)
1314        return name;
1315
1316    name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_linkage_name, nullptr, true);
1317    if (name)
1318        return name;
1319
1320    if (!substitute_name_allowed)
1321        return nullptr;
1322
1323    name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
1324    return name;
1325}
1326
1327
1328//----------------------------------------------------------------------
1329// GetPubname
1330//
1331// Get value the name for a DIE as it should appear for a
1332// .debug_pubnames or .debug_pubtypes section.
1333//----------------------------------------------------------------------
1334const char*
1335DWARFDebugInfoEntry::GetPubname
1336(
1337    SymbolFileDWARF* dwarf2Data,
1338    const DWARFCompileUnit* cu
1339) const
1340{
1341    const char* name = nullptr;
1342    if (!dwarf2Data)
1343        return name;
1344
1345    name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_MIPS_linkage_name, nullptr, true);
1346    if (name)
1347        return name;
1348
1349    name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_linkage_name, nullptr, true);
1350    if (name)
1351        return name;
1352
1353    name = GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
1354    return name;
1355}
1356
1357
1358//----------------------------------------------------------------------
1359// GetName
1360//
1361// Get value of the DW_AT_name attribute for a debug information entry
1362// that exists at offset "die_offset" and place that value into the
1363// supplied stream object. If the DIE is a NULL object "NULL" is placed
1364// into the stream, and if no DW_AT_name attribute exists for the DIE
1365// then nothing is printed.
1366//----------------------------------------------------------------------
1367bool
1368DWARFDebugInfoEntry::GetName
1369(
1370    SymbolFileDWARF* dwarf2Data,
1371    const DWARFCompileUnit* cu,
1372    const dw_offset_t die_offset,
1373    Stream &s
1374)
1375{
1376    if (dwarf2Data == NULL)
1377    {
1378        s.PutCString("NULL");
1379        return false;
1380    }
1381
1382    DWARFDebugInfoEntry die;
1383    lldb::offset_t offset = die_offset;
1384    if (die.Extract(dwarf2Data, cu, &offset))
1385    {
1386        if (die.IsNULL())
1387        {
1388            s.PutCString("NULL");
1389            return true;
1390        }
1391        else
1392        {
1393            const char* name = die.GetAttributeValueAsString(dwarf2Data, cu, DW_AT_name, nullptr, true);
1394            if (name)
1395            {
1396                s.PutCString(name);
1397                return true;
1398            }
1399        }
1400    }
1401    return false;
1402}
1403
1404//----------------------------------------------------------------------
1405// AppendTypeName
1406//
1407// Follows the type name definition down through all needed tags to
1408// end up with a fully qualified type name and dump the results to
1409// the supplied stream. This is used to show the name of types given
1410// a type identifier.
1411//----------------------------------------------------------------------
1412bool
1413DWARFDebugInfoEntry::AppendTypeName
1414(
1415    SymbolFileDWARF* dwarf2Data,
1416    const DWARFCompileUnit* cu,
1417    const dw_offset_t die_offset,
1418    Stream &s
1419)
1420{
1421    if (dwarf2Data == NULL)
1422    {
1423        s.PutCString("NULL");
1424        return false;
1425    }
1426
1427    DWARFDebugInfoEntry die;
1428    lldb::offset_t offset = die_offset;
1429    if (die.Extract(dwarf2Data, cu, &offset))
1430    {
1431        if (die.IsNULL())
1432        {
1433            s.PutCString("NULL");
1434            return true;
1435        }
1436        else
1437        {
1438            const char* name = die.GetPubname(dwarf2Data, cu);
1439            if (name)
1440                s.PutCString(name);
1441            else
1442            {
1443                bool result = true;
1444                const DWARFAbbreviationDeclaration* abbrevDecl = die.GetAbbreviationDeclarationPtr(dwarf2Data, cu, offset);
1445
1446                if (abbrevDecl == NULL)
1447                    return false;
1448
1449                switch (abbrevDecl->Tag())
1450                {
1451                case DW_TAG_array_type:         break;  // print out a "[]" after printing the full type of the element below
1452                case DW_TAG_base_type:          s.PutCString("base ");         break;
1453                case DW_TAG_class_type:         s.PutCString("class ");            break;
1454                case DW_TAG_const_type:         s.PutCString("const ");            break;
1455                case DW_TAG_enumeration_type:   s.PutCString("enum ");         break;
1456                case DW_TAG_file_type:          s.PutCString("file ");         break;
1457                case DW_TAG_interface_type:     s.PutCString("interface ");        break;
1458                case DW_TAG_packed_type:        s.PutCString("packed ");       break;
1459                case DW_TAG_pointer_type:       break;  // print out a '*' after printing the full type below
1460                case DW_TAG_ptr_to_member_type: break;  // print out a '*' after printing the full type below
1461                case DW_TAG_reference_type:     break;  // print out a '&' after printing the full type below
1462                case DW_TAG_restrict_type:      s.PutCString("restrict ");     break;
1463                case DW_TAG_set_type:           s.PutCString("set ");          break;
1464                case DW_TAG_shared_type:        s.PutCString("shared ");       break;
1465                case DW_TAG_string_type:        s.PutCString("string ");       break;
1466                case DW_TAG_structure_type:     s.PutCString("struct ");       break;
1467                case DW_TAG_subrange_type:      s.PutCString("subrange ");     break;
1468                case DW_TAG_subroutine_type:    s.PutCString("function ");     break;
1469                case DW_TAG_thrown_type:        s.PutCString("thrown ");       break;
1470                case DW_TAG_union_type:         s.PutCString("union ");            break;
1471                case DW_TAG_unspecified_type:   s.PutCString("unspecified ");  break;
1472                case DW_TAG_volatile_type:      s.PutCString("volatile ");     break;
1473                default:
1474                    return false;
1475                }
1476
1477                // Follow the DW_AT_type if possible
1478                DWARFFormValue form_value;
1479                if (die.GetAttributeValue(dwarf2Data, cu, DW_AT_type, form_value))
1480                {
1481                    uint64_t next_die_offset = form_value.Reference();
1482                    result = AppendTypeName(dwarf2Data, cu, next_die_offset, s);
1483                }
1484
1485                switch (abbrevDecl->Tag())
1486                {
1487                case DW_TAG_array_type:         s.PutCString("[]");    break;
1488                case DW_TAG_pointer_type:       s.PutChar('*');    break;
1489                case DW_TAG_ptr_to_member_type: s.PutChar('*');    break;
1490                case DW_TAG_reference_type:     s.PutChar('&');    break;
1491                default:
1492                    break;
1493                }
1494                return result;
1495            }
1496        }
1497    }
1498    return false;
1499}
1500
1501bool
1502DWARFDebugInfoEntry::Contains (const DWARFDebugInfoEntry *die) const
1503{
1504    if (die)
1505    {
1506        const dw_offset_t die_offset = die->GetOffset();
1507        if (die_offset > GetOffset())
1508        {
1509            const DWARFDebugInfoEntry *sibling = GetSibling();
1510            assert (sibling); // TODO: take this out
1511            if (sibling)
1512                return die_offset < sibling->GetOffset();
1513        }
1514    }
1515    return false;
1516}
1517
1518//----------------------------------------------------------------------
1519// BuildAddressRangeTable
1520//----------------------------------------------------------------------
1521void
1522DWARFDebugInfoEntry::BuildAddressRangeTable
1523(
1524    SymbolFileDWARF* dwarf2Data,
1525    const DWARFCompileUnit* cu,
1526    DWARFDebugAranges* debug_aranges
1527) const
1528{
1529    if (m_tag)
1530    {
1531        if (m_tag == DW_TAG_subprogram)
1532        {
1533            dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
1534            dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
1535            if (GetAttributeAddressRange(dwarf2Data, cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS))
1536            {
1537                /// printf("BuildAddressRangeTable() 0x%8.8x: %30s: [0x%8.8x - 0x%8.8x)\n", m_offset, DW_TAG_value_to_name(tag), lo_pc, hi_pc);
1538                debug_aranges->AppendRange (cu->GetOffset(), lo_pc, hi_pc);
1539            }
1540        }
1541
1542
1543        const DWARFDebugInfoEntry* child = GetFirstChild();
1544        while (child)
1545        {
1546            child->BuildAddressRangeTable(dwarf2Data, cu, debug_aranges);
1547            child = child->GetSibling();
1548        }
1549    }
1550}
1551
1552//----------------------------------------------------------------------
1553// BuildFunctionAddressRangeTable
1554//
1555// This function is very similar to the BuildAddressRangeTable function
1556// except that the actual DIE offset for the function is placed in the
1557// table instead of the compile unit offset (which is the way the
1558// standard .debug_aranges section does it).
1559//----------------------------------------------------------------------
1560void
1561DWARFDebugInfoEntry::BuildFunctionAddressRangeTable
1562(
1563    SymbolFileDWARF* dwarf2Data,
1564    const DWARFCompileUnit* cu,
1565    DWARFDebugAranges* debug_aranges
1566) const
1567{
1568    if (m_tag)
1569    {
1570        if (m_tag == DW_TAG_subprogram)
1571        {
1572            dw_addr_t lo_pc = LLDB_INVALID_ADDRESS;
1573            dw_addr_t hi_pc = LLDB_INVALID_ADDRESS;
1574            if (GetAttributeAddressRange(dwarf2Data, cu, lo_pc, hi_pc, LLDB_INVALID_ADDRESS))
1575            {
1576            //  printf("BuildAddressRangeTable() 0x%8.8x: [0x%16.16" PRIx64 " - 0x%16.16" PRIx64 ")\n", m_offset, lo_pc, hi_pc); // DEBUG ONLY
1577                debug_aranges->AppendRange (GetOffset(), lo_pc, hi_pc);
1578            }
1579        }
1580
1581        const DWARFDebugInfoEntry* child = GetFirstChild();
1582        while (child)
1583        {
1584            child->BuildFunctionAddressRangeTable(dwarf2Data, cu, debug_aranges);
1585            child = child->GetSibling();
1586        }
1587    }
1588}
1589
1590void
1591DWARFDebugInfoEntry::GetDeclContextDIEs (DWARFCompileUnit* cu,
1592                                         DWARFDIECollection &decl_context_dies) const
1593{
1594
1595    DWARFDIE die (cu, const_cast<DWARFDebugInfoEntry *>(this));
1596    die.GetDeclContextDIEs(decl_context_dies);
1597}
1598
1599void
1600DWARFDebugInfoEntry::GetDWARFDeclContext (SymbolFileDWARF* dwarf2Data,
1601                                          DWARFCompileUnit* cu,
1602                                          DWARFDeclContext &dwarf_decl_ctx) const
1603{
1604    const dw_tag_t tag = Tag();
1605    if (tag != DW_TAG_compile_unit)
1606    {
1607        dwarf_decl_ctx.AppendDeclContext(tag, GetName(dwarf2Data, cu));
1608        DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
1609        if (parent_decl_ctx_die && parent_decl_ctx_die.GetDIE() != this)
1610        {
1611            if (parent_decl_ctx_die.Tag() != DW_TAG_compile_unit)
1612                parent_decl_ctx_die.GetDIE()->GetDWARFDeclContext (parent_decl_ctx_die.GetDWARF(), parent_decl_ctx_die.GetCU(), dwarf_decl_ctx);
1613        }
1614    }
1615}
1616
1617
1618bool
1619DWARFDebugInfoEntry::MatchesDWARFDeclContext (SymbolFileDWARF* dwarf2Data,
1620                                              DWARFCompileUnit* cu,
1621                                              const DWARFDeclContext &dwarf_decl_ctx) const
1622{
1623
1624    DWARFDeclContext this_dwarf_decl_ctx;
1625    GetDWARFDeclContext (dwarf2Data, cu, this_dwarf_decl_ctx);
1626    return this_dwarf_decl_ctx == dwarf_decl_ctx;
1627}
1628
1629DWARFDIE
1630DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
1631											  DWARFCompileUnit* cu) const
1632{
1633	DWARFAttributes attributes;
1634	GetAttributes(cu, DWARFFormValue::FixedFormSizes(), attributes);
1635	return GetParentDeclContextDIE (dwarf2Data, cu, attributes);
1636}
1637
1638DWARFDIE
1639DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data,
1640											  DWARFCompileUnit* cu,
1641											  const DWARFAttributes& attributes) const
1642{
1643    DWARFDIE die (cu, const_cast<DWARFDebugInfoEntry *>(this));
1644
1645	while (die)
1646	{
1647		// If this is the original DIE that we are searching for a declaration
1648		// for, then don't look in the cache as we don't want our own decl
1649		// context to be our decl context...
1650		if (die.GetDIE() != this)
1651		{
1652			switch (die.Tag())
1653			{
1654				case DW_TAG_compile_unit:
1655				case DW_TAG_namespace:
1656				case DW_TAG_structure_type:
1657				case DW_TAG_union_type:
1658				case DW_TAG_class_type:
1659					return die;
1660
1661				default:
1662					break;
1663			}
1664		}
1665
1666		dw_offset_t die_offset;
1667
1668		die_offset = attributes.FormValueAsUnsigned(DW_AT_specification, DW_INVALID_OFFSET);
1669		if (die_offset != DW_INVALID_OFFSET)
1670		{
1671			DWARFDIE spec_die = cu->GetDIE (die_offset);
1672			if (spec_die)
1673            {
1674                DWARFDIE decl_ctx_die = spec_die.GetParentDeclContextDIE();
1675                if (decl_ctx_die)
1676                    return decl_ctx_die;
1677            }
1678		}
1679
1680        die_offset = attributes.FormValueAsUnsigned(DW_AT_abstract_origin, DW_INVALID_OFFSET);
1681		if (die_offset != DW_INVALID_OFFSET)
1682		{
1683            DWARFDIE abs_die = cu->GetDIE (die_offset);
1684			if (abs_die)
1685			{
1686                DWARFDIE decl_ctx_die = abs_die.GetParentDeclContextDIE();
1687                if (decl_ctx_die)
1688                    return decl_ctx_die;
1689			}
1690		}
1691
1692		die = die.GetParent();
1693	}
1694    return DWARFDIE();
1695}
1696
1697
1698const char *
1699DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data,
1700									   DWARFCompileUnit* cu,
1701									   std::string &storage) const
1702{
1703	DWARFAttributes attributes;
1704	GetAttributes(cu, DWARFFormValue::FixedFormSizes(), attributes);
1705	return GetQualifiedName (dwarf2Data, cu, attributes, storage);
1706}
1707
1708const char*
1709DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data,
1710									   DWARFCompileUnit* cu,
1711									   const DWARFAttributes& attributes,
1712									   std::string &storage) const
1713{
1714
1715	const char *name = GetName (dwarf2Data, cu);
1716
1717	if (name)
1718	{
1719		DWARFDIE parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu);
1720		storage.clear();
1721		// TODO: change this to get the correct decl context parent....
1722		while (parent_decl_ctx_die)
1723		{
1724			const dw_tag_t parent_tag = parent_decl_ctx_die.Tag();
1725			switch (parent_tag)
1726			{
1727                case DW_TAG_namespace:
1728                    {
1729                        const char *namespace_name = parent_decl_ctx_die.GetName ();
1730                        if (namespace_name)
1731                        {
1732                            storage.insert (0, "::");
1733                            storage.insert (0, namespace_name);
1734                        }
1735                        else
1736                        {
1737                            storage.insert (0, "(anonymous namespace)::");
1738                        }
1739                        parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
1740                    }
1741                    break;
1742
1743                case DW_TAG_class_type:
1744                case DW_TAG_structure_type:
1745                case DW_TAG_union_type:
1746                    {
1747                        const char *class_union_struct_name = parent_decl_ctx_die.GetName ();
1748
1749                        if (class_union_struct_name)
1750                        {
1751                            storage.insert (0, "::");
1752                            storage.insert (0, class_union_struct_name);
1753                        }
1754                        parent_decl_ctx_die = parent_decl_ctx_die.GetParentDeclContextDIE();
1755                    }
1756                    break;
1757
1758                default:
1759                    parent_decl_ctx_die.Clear();
1760                    break;
1761			}
1762		}
1763
1764		if (storage.empty())
1765			storage.append ("::");
1766
1767		storage.append (name);
1768	}
1769	if (storage.empty())
1770		return NULL;
1771	return storage.c_str();
1772}
1773
1774
1775//----------------------------------------------------------------------
1776// LookupAddress
1777//----------------------------------------------------------------------
1778bool
1779DWARFDebugInfoEntry::LookupAddress
1780(
1781    const dw_addr_t address,
1782    SymbolFileDWARF* dwarf2Data,
1783    const DWARFCompileUnit* cu,
1784    DWARFDebugInfoEntry** function_die,
1785    DWARFDebugInfoEntry** block_die
1786)
1787{
1788    bool found_address = false;
1789    if (m_tag)
1790    {
1791        bool check_children = false;
1792        bool match_addr_range = false;
1793    //  printf("0x%8.8x: %30s: address = 0x%8.8x - ", m_offset, DW_TAG_value_to_name(tag), address);
1794        switch (m_tag)
1795        {
1796        case DW_TAG_array_type                 : break;
1797        case DW_TAG_class_type                 : check_children = true; break;
1798        case DW_TAG_entry_point                : break;
1799        case DW_TAG_enumeration_type           : break;
1800        case DW_TAG_formal_parameter           : break;
1801        case DW_TAG_imported_declaration       : break;
1802        case DW_TAG_label                      : break;
1803        case DW_TAG_lexical_block              : check_children = true; match_addr_range = true; break;
1804        case DW_TAG_member                     : break;
1805        case DW_TAG_pointer_type               : break;
1806        case DW_TAG_reference_type             : break;
1807        case DW_TAG_compile_unit               : match_addr_range = true; break;
1808        case DW_TAG_string_type                : break;
1809        case DW_TAG_structure_type             : check_children = true; break;
1810        case DW_TAG_subroutine_type            : break;
1811        case DW_TAG_typedef                    : break;
1812        case DW_TAG_union_type                 : break;
1813        case DW_TAG_unspecified_parameters     : break;
1814        case DW_TAG_variant                    : break;
1815        case DW_TAG_common_block               : check_children = true; break;
1816        case DW_TAG_common_inclusion           : break;
1817        case DW_TAG_inheritance                : break;
1818        case DW_TAG_inlined_subroutine         : check_children = true; match_addr_range = true; break;
1819        case DW_TAG_module                     : match_addr_range = true; break;
1820        case DW_TAG_ptr_to_member_type         : break;
1821        case DW_TAG_set_type                   : break;
1822        case DW_TAG_subrange_type              : break;
1823        case DW_TAG_with_stmt                  : break;
1824        case DW_TAG_access_declaration         : break;
1825        case DW_TAG_base_type                  : break;
1826        case DW_TAG_catch_block                : match_addr_range = true; break;
1827        case DW_TAG_const_type                 : break;
1828        case DW_TAG_constant                   : break;
1829        case DW_TAG_enumerator                 : break;
1830        case DW_TAG_file_type                  : break;
1831        case DW_TAG_friend                     : break;
1832        case DW_TAG_namelist                   : break;
1833        case DW_TAG_namelist_item              : break;
1834        case DW_TAG_packed_type                : break;
1835        case DW_TAG_subprogram                 : match_addr_range = true; break;
1836        case DW_TAG_template_type_parameter    : break;
1837        case DW_TAG_template_value_parameter   : break;
1838        case DW_TAG_thrown_type                : break;
1839        case DW_TAG_try_block                  : match_addr_range = true; break;
1840        case DW_TAG_variant_part               : break;
1841        case DW_TAG_variable                   : break;
1842        case DW_TAG_volatile_type              : break;
1843        case DW_TAG_dwarf_procedure            : break;
1844        case DW_TAG_restrict_type              : break;
1845        case DW_TAG_interface_type             : break;
1846        case DW_TAG_namespace                  : check_children = true; break;
1847        case DW_TAG_imported_module            : break;
1848        case DW_TAG_unspecified_type           : break;
1849        case DW_TAG_partial_unit               : break;
1850        case DW_TAG_imported_unit              : break;
1851        case DW_TAG_shared_type                : break;
1852        default: break;
1853        }
1854
1855        if (match_addr_range)
1856        {
1857            dw_addr_t lo_pc = GetAttributeValueAsAddress(dwarf2Data, cu, DW_AT_low_pc, LLDB_INVALID_ADDRESS);
1858            if (lo_pc != LLDB_INVALID_ADDRESS)
1859            {
1860                dw_addr_t hi_pc = GetAttributeHighPC(dwarf2Data, cu, lo_pc, LLDB_INVALID_ADDRESS);
1861                if (hi_pc != LLDB_INVALID_ADDRESS)
1862                {
1863                    //  printf("\n0x%8.8x: %30s: address = 0x%8.8x  [0x%8.8x - 0x%8.8x) ", m_offset, DW_TAG_value_to_name(tag), address, lo_pc, hi_pc);
1864                    if ((lo_pc <= address) && (address < hi_pc))
1865                    {
1866                        found_address = true;
1867                    //  puts("***MATCH***");
1868                        switch (m_tag)
1869                        {
1870                        case DW_TAG_compile_unit:       // File
1871                            check_children = ((function_die != NULL) || (block_die != NULL));
1872                            break;
1873
1874                        case DW_TAG_subprogram:         // Function
1875                            if (function_die)
1876                                *function_die = this;
1877                            check_children = (block_die != NULL);
1878                            break;
1879
1880                        case DW_TAG_inlined_subroutine: // Inlined Function
1881                        case DW_TAG_lexical_block:      // Block { } in code
1882                            if (block_die)
1883                            {
1884                                *block_die = this;
1885                                check_children = true;
1886                            }
1887                            break;
1888
1889                        default:
1890                            check_children = true;
1891                            break;
1892                        }
1893                    }
1894                }
1895                else
1896                {   // compile units may not have a valid high/low pc when there
1897                    // are address gaps in subroutines so we must always search
1898                    // if there is no valid high and low PC
1899                    check_children = (m_tag == DW_TAG_compile_unit) && ((function_die != NULL) || (block_die != NULL));
1900                }
1901            }
1902            else
1903            {
1904                dw_offset_t debug_ranges_offset = GetAttributeValueAsUnsigned(dwarf2Data, cu, DW_AT_ranges, DW_INVALID_OFFSET);
1905                if (debug_ranges_offset != DW_INVALID_OFFSET)
1906                {
1907                    DWARFRangeList ranges;
1908                    DWARFDebugRanges* debug_ranges = dwarf2Data->DebugRanges();
1909                    debug_ranges->FindRanges(debug_ranges_offset, ranges);
1910                    // All DW_AT_ranges are relative to the base address of the
1911                    // compile unit. We add the compile unit base address to make
1912                    // sure all the addresses are properly fixed up.
1913                    ranges.Slide (cu->GetBaseAddress());
1914                    if (ranges.FindEntryThatContains(address))
1915                    {
1916                        found_address = true;
1917                    //  puts("***MATCH***");
1918                        switch (m_tag)
1919                        {
1920                        case DW_TAG_compile_unit:       // File
1921                            check_children = ((function_die != NULL) || (block_die != NULL));
1922                            break;
1923
1924                        case DW_TAG_subprogram:         // Function
1925                            if (function_die)
1926                                *function_die = this;
1927                            check_children = (block_die != NULL);
1928                            break;
1929
1930                        case DW_TAG_inlined_subroutine: // Inlined Function
1931                        case DW_TAG_lexical_block:      // Block { } in code
1932                            if (block_die)
1933                            {
1934                                *block_die = this;
1935                                check_children = true;
1936                            }
1937                            break;
1938
1939                        default:
1940                            check_children = true;
1941                            break;
1942                        }
1943                    }
1944                    else
1945                    {
1946                        check_children = false;
1947                    }
1948                }
1949            }
1950        }
1951
1952
1953        if (check_children)
1954        {
1955        //  printf("checking children\n");
1956            DWARFDebugInfoEntry* child = GetFirstChild();
1957            while (child)
1958            {
1959                if (child->LookupAddress(address, dwarf2Data, cu, function_die, block_die))
1960                    return true;
1961                child = child->GetSibling();
1962            }
1963        }
1964    }
1965    return found_address;
1966}
1967
1968const DWARFAbbreviationDeclaration*
1969DWARFDebugInfoEntry::GetAbbreviationDeclarationPtr (SymbolFileDWARF* dwarf2Data,
1970                                                    const DWARFCompileUnit *cu,
1971                                                    lldb::offset_t &offset) const
1972{
1973    if (dwarf2Data)
1974    {
1975        offset = GetOffset();
1976
1977        const DWARFAbbreviationDeclarationSet *abbrev_set = cu->GetAbbreviations();
1978        if (abbrev_set)
1979        {
1980            const DWARFAbbreviationDeclaration* abbrev_decl = abbrev_set->GetAbbreviationDeclaration (m_abbr_idx);
1981            if (abbrev_decl)
1982            {
1983                // Make sure the abbreviation code still matches. If it doesn't and
1984                // the DWARF data was mmap'ed, the backing file might have been modified
1985                // which is bad news.
1986                const uint64_t abbrev_code = dwarf2Data->get_debug_info_data().GetULEB128 (&offset);
1987
1988                if (abbrev_decl->Code() == abbrev_code)
1989                    return abbrev_decl;
1990
1991                dwarf2Data->GetObjectFile()->GetModule()->ReportErrorIfModifyDetected ("0x%8.8x: the DWARF debug information has been modified (abbrev code was %u, and is now %u)",
1992                                                                                       GetOffset(),
1993                                                                                       (uint32_t)abbrev_decl->Code(),
1994                                                                                       (uint32_t)abbrev_code);
1995            }
1996        }
1997    }
1998    offset = DW_INVALID_OFFSET;
1999    return NULL;
2000}
2001
2002
2003bool
2004DWARFDebugInfoEntry::OffsetLessThan (const DWARFDebugInfoEntry& a, const DWARFDebugInfoEntry& b)
2005{
2006    return a.GetOffset() < b.GetOffset();
2007}
2008
2009void
2010DWARFDebugInfoEntry::DumpDIECollection (Stream &strm, DWARFDebugInfoEntry::collection &die_collection)
2011{
2012    DWARFDebugInfoEntry::const_iterator pos;
2013    DWARFDebugInfoEntry::const_iterator end = die_collection.end();
2014    strm.PutCString("\noffset    parent   sibling  child\n");
2015    strm.PutCString("--------  -------- -------- --------\n");
2016    for (pos = die_collection.begin(); pos != end; ++pos)
2017    {
2018        const DWARFDebugInfoEntry& die_ref = *pos;
2019        const DWARFDebugInfoEntry* p = die_ref.GetParent();
2020        const DWARFDebugInfoEntry* s = die_ref.GetSibling();
2021        const DWARFDebugInfoEntry* c = die_ref.GetFirstChild();
2022        strm.Printf("%.8x: %.8x %.8x %.8x 0x%4.4x %s%s\n",
2023                    die_ref.GetOffset(),
2024                    p ? p->GetOffset() : 0,
2025                    s ? s->GetOffset() : 0,
2026                    c ? c->GetOffset() : 0,
2027                    die_ref.Tag(),
2028                    DW_TAG_value_to_name(die_ref.Tag()),
2029                    die_ref.HasChildren() ? " *" : "");
2030    }
2031}
2032
2033
2034