<div dir="ltr"><div>I think we have to be careful here. We might want flexibility to say "I want to use a specific class" without having to specify the exact DW_FORM. Sometimes, we might even end up in an ambiguous situation and not get the result we want. For example, in DWARFv4, the DW_AT_high_pc attribute has either a Constant or an Address class, which use completely different forms, but if we have just "Value: 0x1234", which is it? In DWARFv3, it is always an Address, if I remember correctly, so in that case, we might want our default to be "Address". However, for DWARFv4 the compiler typically emits DW_AT_high_pc using a Constant form, and most people might expect that to be used instead.</div><div><br></div><div>I think having a different name for the tag might be a good thing to do, with the name matching the different classes (of which there are 15 in DWARFv5, possibly with some folded together like string/stroffsetsptr), but it could be a little confusing as Pavel mentions. Alternatively, maybe we could have Value and Form, where the Form can be a generic class name instead of a specific DW_FORM value. This has the potential for ambiguity still, but should be flexible enough at least.</div><div><br></div><div>James<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 22 May 2020 at 10:46, Pavel Labath via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 22/05/2020 10:38, Xing GUO wrote:<br>
>  BTW, I think<br>
> the value of "DW_AT_decl_file" shall be "Str"? Can we map the values<br>
> of different types into same field?<br>
> <br>
> """<br>
> - Attr: DW_AT_decl_file<br>
>   Str: foo<br>
> """<br>
Yes, that is definitely possible. You just need to make the map calls<br>
conditional on the values of other attributes. Maybe something like this:<br>
IO.mapRequired("Attr", Attr);<br>
IO.mapOptional("Form", Form, getDefaultForm(Attr, Ctx.isSplitDwarf()<br>
/*or whatever*/));<br>
switch (getFormClass(Form)) {<br>
/* The cases could correspond to DWARF5 form classes, but maybe not<br>
completely.*/<br>
case String: IO.mapRequired("Value", Value.String);<br>
case Constant: IO.mapRequired("Value", Value.Int);<br>
case Block: IO.mapRequired("Value", Value.Bytes);<br>
...<br>
}<br>
<br>
<br>
I think doing something like that would be reasonable, because i expect<br>
a relatively high number of "classes", and I think it might be tricky to<br>
remember which key to use for which value type.<br>
<br>
cheers,<br>
Pavel<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>