[PATCH] D24425: DebugInfo: support for DWARFv5 DW_AT_alignment attribute

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 6 09:38:05 PDT 2016


aprantl added inline comments.


> SourceLevelDebugging.rst:450
> +for DW_AT_alignment value.
> +
>  C/C++ function information

Thanks!!

> vleschuk wrote in DwarfCompileUnit.cpp:779
> I think it can be NULL: class DbgVariable doesn't check its DILocalVariable * member for being NULL when being constructed or accessed.

Hmm. I don't think it makes sense to ever construct a DbgVariable without a variable. We should probably change it to a reference at some point. Thanks for checking.

> DwarfUnit.cpp:1415
>        // is non-zero if and only if alignment was forced (e.g. _Alignas()),
>        // which can't be done with bitfields. Thus we use FieldSize here.
>        uint64_t AlignInBits = FieldSize;

What about packed structs?

Sorry, I'm just being very cautious about any changes here, because every single time I touched this code in that past I broke the either LLDB or GDB ;-)

A couple of examples from the testsuite you can run through clang with both -gdwarf-2 and -gdwarf-4 and verify that the DWARF output didn't change:

  #pragma pack(1)
      struct PackedBits
       {
          char a;
          uint32_t b : 5,
          c : 27
        } s;
     #pragma pack()
  
   struct bitfield {
      int a : 2;
      int b : 32;
      int c : 1;
      int d : 28;
  }
  
  struct size8 {
    int i : 4;
    long long l : 60;
  };
  
  
  struct layout0 {
    char l0_ofs0;
    struct size8 l0_ofs8;
    int l0_ofs16 : 1;
  };
  
  struct size8_anon {
    int : 4;
    long long : 60;
  };
  struct layout1 {
    char l1_ofs0;
    struct size8_anon l1_ofs1;
    int l1_ofs9 : 1;
  };
  
  #pragma pack(1)
  struct size8_pack1 {
    int i : 4;
    long long l : 60;
  };
  struct layout2 {
    char l2_ofs0;
    struct size8_pack1 l2_ofs1;
    int l2_ofs9 : 1;
  };
  #pragma pack()
  
  #pragma pack(4)
  struct size8_pack4 {
    int i : 4;
    long long l : 60;
  };
  struct layout3 {
    char l3_ofs0;
    struct size8_pack4 l3_ofs4;
    int l3_ofs12 : 1;
  };
  #pragma pack()

https://reviews.llvm.org/D24425





More information about the llvm-commits mailing list