public static void Print(this DwarfDIE die, TextWriter writer, int level = 0) { if (writer == null) { throw new ArgumentNullException(nameof(writer)); } writer.WriteLine($" <{level}><{die.Offset:x}>: Abbrev Number: {die.Abbrev.Code} ({die.Tag})"); foreach (var attr in die.Attributes) { string attrValue = null; switch (attr.ValueAsObject) { case DwarfDIE dieRef: attrValue = $"<0x{dieRef.Offset:x}>"; break; case string str: attrValue = str; break; case DwarfExpression expr: attrValue = $"{expr.Operations.Count} OpCodes ({string.Join(", ", expr.Operations.Select(x => x.Kind))})"; break; } switch (attr.Kind.Value) { case DwarfAttributeKind.Language: attrValue = $"{attr.ValueAsU64} {GetLanguageKind((DwarfLanguageKind)attr.ValueAsU64)}"; break; } if (attrValue == null) { var encoding = DwarfHelper.GetAttributeEncoding(attr.Kind); if ((encoding & DwarfAttributeEncoding.Address) != 0) { attrValue = $"0x{attr.ValueAsU64:x}"; } else { attrValue = $"{attr.ValueAsU64}"; } } writer.WriteLine($" <{attr.Offset:x}> {attr.Kind,-18} : {attrValue}"); } foreach (var child in die.Children) { Print(child, writer, level + 1); } }
public DwarfConstant(DwarfDIE dieRef) { AsValue = default; AsObject = dieRef; }
internal void PushDIE(DwarfDIE die) { _registeredDIEPerCompilationUnit.Add(die.Offset - CurrentUnit.Offset, die); _registeredDIEPerSection.Add(die.Offset, die); _stack.Push(die); }