<div dir="ltr">Ah, thanks for the catch(es) - sent out <a href="https://reviews.llvm.org/D55721">https://reviews.llvm.org/D55721</a> for discussion.</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Dec 14, 2018 at 1:48 PM <<a href="mailto:paul.robinson@sony.com">paul.robinson@sony.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm not saying revert this, but there are problems with it, so please<br>
post a review that addresses the problems and we can have a wider<br>
discussion of the display syntax. See specific comments inline.<br>
Thanks,<br>
--paulr<br>
<br>
> -----Original Message-----<br>
> From: llvm-commits [mailto:<a href="mailto:llvm-commits-bounces@lists.llvm.org" target="_blank">llvm-commits-bounces@lists.llvm.org</a>] On Behalf<br>
> Of David Blaikie via llvm-commits<br>
> Sent: Wednesday, December 12, 2018 1:46 PM<br>
> To: <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
> Subject: [llvm] r348954 - llvm-dwarfdump: Dump array dimensions in<br>
> stringified type names<br>
> <br>
> Author: dblaikie<br>
> Date: Wed Dec 12 10:46:25 2018<br>
> New Revision: 348954<br>
> <br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=348954&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=348954&view=rev</a><br>
> Log:<br>
> llvm-dwarfdump: Dump array dimensions in stringified type names<br>
> <br>
> Added:<br>
> llvm/trunk/test/tools/llvm-dwarfdump/X86/prettyprint_types.s<br>
> Modified:<br>
> llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp<br>
> <br>
> Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp?rev=348954&r1=348953&r<br>
> 2=348954&view=diff<br>
> ==========================================================================<br>
> ====<br>
> --- llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp (original)<br>
> +++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDie.cpp Wed Dec 12 10:46:25 2018<br>
> @@ -184,9 +184,28 @@ static void dumpTypeName(raw_ostream &OS<br>
> dumpTypeName(OS, D);<br>
> <br>
> switch (T) {<br>
> - case DW_TAG_array_type:<br>
> - OS << "[]";<br>
> + case DW_TAG_array_type: {<br>
> +<br>
> + Optional<uint64_t> Bound;<br>
> + for (const DWARFDie &C : D.children())<br>
> + if (C.getTag() == DW_TAG_subrange_type) {<br>
> + OS << '[';<br>
> + uint64_t LowerBound = 0;<br>
<br>
The default lower bound is language-dependent. This has knock-on<br>
effects...<br>
<br>
> + if (Optional<DWARFFormValue> L = C.find(DW_AT_lower_bound))<br>
> + if (Optional<uint64_t> LB = L->getAsUnsignedConstant()) {<br>
> + LowerBound = *LB;<br>
> + OS << LowerBound << '-';<br>
> + }<br>
> + if (Optional<DWARFFormValue> CountV = C.find(DW_AT_count)) {<br>
> + if (Optional<uint64_t> C = CountV->getAsUnsignedConstant())<br>
> + OS << (*C + LowerBound);<br>
> + } else if (Optional<DWARFFormValue> UpperV =<br>
> C.find(DW_AT_upper_bound))<br>
> + if (Optional<uint64_t> U = UpperV->getAsUnsignedConstant())<br>
> + OS << *U;<br>
<br>
The upper-bound-only and count-only cases look alike, and it's not clear<br>
how you intend a simple [2] to be interpreted. [2] as a count for a<br>
default lower bound of 0 means the same as [0-1], but as an upper bound<br>
with a default lower bound of 1 it means the same as [1-2].<br>
<br>
<br>
> + OS << ']';<br>
> + }<br>
> break;<br>
> + }<br>
> case DW_TAG_pointer_type:<br>
> OS << '*';<br>
> break;<br>
> <br>
> Added: llvm/trunk/test/tools/llvm-dwarfdump/X86/prettyprint_types.s<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-</a><br>
> dwarfdump/X86/prettyprint_types.s?rev=348954&view=auto<br>
> ==========================================================================<br>
> ====<br>
> --- llvm/trunk/test/tools/llvm-dwarfdump/X86/prettyprint_types.s (added)<br>
> +++ llvm/trunk/test/tools/llvm-dwarfdump/X86/prettyprint_types.s Wed Dec<br>
> 12 10:46:25 2018<br>
> @@ -0,0 +1,179 @@<br>
> +# RUN: llvm-mc < %s -filetype obj -triple i386-pc-linux -o - \<br>
> +# RUN: | llvm-dwarfdump - | FileCheck %s<br>
> +<br>
> +# CHECK: DW_TAG_variable<br>
> +<br>
> +# base_type<br>
> +# CHECK: DW_AT_type{{.*}}"int"<br>
> +<br>
> +# pointer_type<br>
> +# CHECK: DW_AT_type{{.*}}"int*"<br>
> +<br>
> +# reference_type<br>
> +# CHECK: DW_AT_type{{.*}}"int&"<br>
> +<br>
> +# rvalue_reference_type<br>
> +# CHECK: DW_AT_type{{.*}}"int&&"<br>
> +<br>
> +# ptr_to_member_type<br>
> +# FIXME: Add the contained_type to the assembly, and test the print out<br>
> is "int foo::*"<br>
> +# CHECK: DW_AT_type{{.*}}"int*"<br>
> +<br>
> +# array_type<br>
> +# Testing lower_bound, upper_bound, lower and upper, lower and count, and<br>
> count separately.<br>
> +# CHECK: DW_AT_type{{.*}}"int[1-][2][1-2][1-3][2]"<br>
^^^^^<br>
This one appears to be for lower_bound=1,count=2, which should be [1-2].<br>
<br>
These CHECKs are pretty far away from where the DIEs are defined, which makes<br>
it not so easy to verify that they're correct.<br>
<br>
> +<br>
> + .section .debug_str,"MS",@progbits,1<br>
> +.Lint_name:<br>
> + .asciz "int" # string offset=107<br>
> + .section .debug_abbrev,"",@progbits<br>
> + .byte 1 # Abbreviation Code<br>
> + .byte 17 # DW_TAG_compile_unit<br>
> + .byte 1 # DW_CHILDREN_yes<br>
> + .byte 19 # DW_AT_language<br>
> + .byte 5 # DW_FORM_data2<br>
> + .byte 0 # EOM(1)<br>
> + .byte 0 # EOM(2)<br>
> + .byte 2 # Abbreviation Code<br>
> + .byte 36 # DW_TAG_base_type<br>
> + .byte 0 # DW_CHILDREN_no<br>
> + .byte 3 # DW_AT_name<br>
> + .byte 14 # DW_FORM_strp<br>
> + .byte 0 # EOM(1)<br>
> + .byte 0 # EOM(2)<br>
> + .byte 3 # Abbreviation Code<br>
> + .byte 52 # DW_TAG_variable<br>
> + .byte 0 # DW_CHILDREN_no<br>
> + .byte 73 # DW_AT_type<br>
> + .byte 19 # DW_FORM_ref4<br>
> + .byte 0 # EOM(1)<br>
> + .byte 0 # EOM(2)<br>
> + .byte 4 # Abbreviation Code<br>
> + .byte 0xf # DW_TAG_pointer_type<br>
> + .byte 0 # DW_CHILDREN_no<br>
> + .byte 73 # DW_AT_type<br>
> + .byte 19 # DW_FORM_ref4<br>
> + .byte 0 # EOM(1)<br>
> + .byte 0 # EOM(2)<br>
> + .byte 5 # Abbreviation Code<br>
> + .byte 0x10 # DW_TAG_reference_type<br>
> + .byte 0 # DW_CHILDREN_no<br>
> + .byte 73 # DW_AT_type<br>
> + .byte 19 # DW_FORM_ref4<br>
> + .byte 0 # EOM(1)<br>
> + .byte 0 # EOM(2)<br>
> + .byte 6 # Abbreviation Code<br>
> + .byte 0x42 # DW_TAG_rvalue_reference_type<br>
> + .byte 0 # DW_CHILDREN_no<br>
> + .byte 73 # DW_AT_type<br>
> + .byte 19 # DW_FORM_ref4<br>
> + .byte 0 # EOM(1)<br>
> + .byte 0 # EOM(2)<br>
> + .byte 7 # Abbreviation Code<br>
> + .byte 0x1f # DW_TAG_ptr_to_member_type<br>
> + .byte 0 # DW_CHILDREN_no<br>
> + .byte 73 # DW_AT_type<br>
> + .byte 19 # DW_FORM_ref4<br>
> + .byte 0 # EOM(1)<br>
> + .byte 0 # EOM(2)<br>
> + .byte 8 # Abbreviation Code<br>
> + .byte 1 # DW_TAG_array_type<br>
> + .byte 1 # DW_CHILDREN_yes<br>
> + .byte 73 # DW_AT_type<br>
> + .byte 19 # DW_FORM_ref4<br>
> + .byte 0 # EOM(1)<br>
> + .byte 0 # EOM(2)<br>
> + .byte 9 # Abbreviation Code<br>
> + .byte 0x21 # DW_TAG_subrange_type<br>
> + .byte 0 # DW_CHILDREN_no<br>
> + .byte 0x22 # DW_AT_lower_bound<br>
> + .byte 0xb # DW_FORM_data1<br>
> + .byte 0 # EOM(1)<br>
> + .byte 0 # EOM(2)<br>
> + .byte 10 # Abbreviation Code<br>
> + .byte 0x21 # DW_TAG_subrange_type<br>
> + .byte 0 # DW_CHILDREN_no<br>
> + .byte 0x2f # DW_AT_upper_bound<br>
> + .byte 0xb # DW_FORM_data1<br>
> + .byte 0 # EOM(1)<br>
> + .byte 0 # EOM(2)<br>
> + .byte 11 # Abbreviation Code<br>
> + .byte 0x21 # DW_TAG_subrange_type<br>
> + .byte 0 # DW_CHILDREN_no<br>
> + .byte 0x22 # DW_AT_lower_bound<br>
> + .byte 0xb # DW_FORM_data1<br>
> + .byte 0x2f # DW_AT_upper_bound<br>
> + .byte 0xb # DW_FORM_data1<br>
> + .byte 0 # EOM(1)<br>
> + .byte 0 # EOM(2)<br>
> + .byte 12 # Abbreviation Code<br>
> + .byte 0x21 # DW_TAG_subrange_type<br>
> + .byte 0 # DW_CHILDREN_no<br>
> + .byte 0x22 # DW_AT_lower_bound<br>
> + .byte 0xb # DW_FORM_data1<br>
> + .byte 0x37 # DW_AT_count<br>
> + .byte 0xb # DW_FORM_data1<br>
> + .byte 0 # EOM(1)<br>
> + .byte 0 # EOM(2)<br>
> + .byte 13 # Abbreviation Code<br>
> + .byte 0x21 # DW_TAG_subrange_type<br>
> + .byte 0 # DW_CHILDREN_no<br>
> + .byte 0x37 # DW_AT_count<br>
> + .byte 0xb # DW_FORM_data1<br>
> + .byte 0 # EOM(1)<br>
> + .byte 0 # EOM(2)<br>
> + .byte 0 # EOM(3)<br>
> + .section .debug_info,"",@progbits<br>
> +.Lcu_begin:<br>
> + .long .Lunit_end - .Lunit_start # Length of Unit<br>
> +.Lunit_start:<br>
> + .short 4 # DWARF version number<br>
> + .long .debug_abbrev # Offset Into Abbrev. Section<br>
> + .byte 8 # Address Size (in bytes)<br>
> + .byte 1 # DW_TAG_compile_unit<br>
> + .short 12 # DW_AT_language<br>
> +.Lint_type:<br>
> + .byte 2 # DW_TAG_base_type<br>
> + .long .Lint_name # DW_AT_name<br>
> +.Lpointer_type:<br>
> + .byte 4 # DW_TAG_pointer_type<br>
> + .long .Lint_type - .Lcu_begin # DW_AT_type<br>
> +.Lreference_type:<br>
> + .byte 5 # DW_TAG_reference_type<br>
> + .long .Lint_type - .Lcu_begin # DW_AT_type<br>
> +.Lrvalue_reference_type:<br>
> + .byte 6 # DW_TAG_rvalue_reference_type<br>
> + .long .Lint_type - .Lcu_begin # DW_AT_type<br>
> +.Lptr_to_member_type:<br>
> + .byte 7 # DW_TAG_ptr_to_member_type<br>
> + .long .Lint_type - .Lcu_begin # DW_AT_type<br>
> +.Larray_type:<br>
> + .byte 8 # DW_TAG_array_type<br>
> + .long .Lint_type - .Lcu_begin # DW_AT_type<br>
> + .byte 9 # DW_AT_subrange_type<br>
> + .byte 1 # DW_AT_lower_bound<br>
> + .byte 10 # DW_AT_subrange_type<br>
> + .byte 2 # DW_AT_upper_bound<br>
> + .byte 11 # DW_AT_subrange_type<br>
> + .byte 1 # DW_AT_lower_bound<br>
> + .byte 2 # DW_AT_upper_bound<br>
> + .byte 12 # DW_AT_subrange_type<br>
> + .byte 1 # DW_AT_lower_bound<br>
> + .byte 2 # DW_AT_count<br>
> + .byte 13 # DW_AT_subrange_type<br>
> + .byte 2 # DW_AT_count<br>
> + .byte 0 # End Of Children Mark<br>
> + .byte 3 # DW_TAG_variable<br>
> + .long .Lint_type - .Lcu_begin # DW_AT_type<br>
> + .byte 3 # DW_TAG_variable<br>
> + .long .Lpointer_type - .Lcu_begin # DW_AT_type<br>
> + .byte 3 # DW_TAG_variable<br>
> + .long .Lreference_type - .Lcu_begin # DW_AT_type<br>
> + .byte 3 # DW_TAG_variable<br>
> + .long .Lrvalue_reference_type - .Lcu_begin # DW_AT_type<br>
> + .byte 3 # DW_TAG_variable<br>
> + .long .Lptr_to_member_type - .Lcu_begin # DW_AT_type<br>
> + .byte 3 # DW_TAG_variable<br>
> + .long .Larray_type - .Lcu_begin # DW_AT_type<br>
> + .byte 0 # End Of Children Mark<br>
> +.Lunit_end:<br>
> <br>
> <br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>