[llvm] r348954 - llvm-dwarfdump: Dump array dimensions in stringified type names

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 14 14:22:00 PST 2018


Ah, thanks for the catch(es) - sent out https://reviews.llvm.org/D55721 for
discussion.

On Fri, Dec 14, 2018 at 1:48 PM <paul.robinson at sony.com> wrote:

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


More information about the llvm-commits mailing list