[PATCH] D82881: [DEBUGINFO]Fix debug info for packed bitfields.

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 7 04:29:03 PDT 2020


ABataev added a comment.

In D82881#2134913 <https://reviews.llvm.org/D82881#2134913>, @dblaikie wrote:

> In D82881#2133548 <https://reviews.llvm.org/D82881#2133548>, @ABataev wrote:
>
> > In D82881#2133511 <https://reviews.llvm.org/D82881#2133511>, @aprantl wrote:
> >
> > > And conversely, with this patch applied, do GDB and LLDB still produce the expected result?
> >
> >
> > GDB works correctly. Did not check with lldb, but it also should work. The result is similar to the debug info, produced for the next code:
> >
> >   struct {
> >   short : 3;
> >   short : 6;
> >   } a;
> >
>
>
> Similar, but seems different in a critical way - in that code, the type of the field is short, which has size 2. Which matches the size of the field.
>
> I think it would be pretty surprising to handle DWARF where the size of a field is different from the size of the type of that field?


The standard clearly says:
A base type entry has a DW_AT_byte_size attribute, whose value is a constant, describing the size in bytes of the storage unit used to represent an object of the given type.
In our example, the storage size is the same, just like for short. The standard does not say anything about the size of the base type. The real size of the bitfield is passed in `DW_AT_bit_size` attribute (in bits).

> That said, I don't have great suggestions for how the DWARF should communicate this packed situation where a bitfield crosses a byte boundary either.
> 
>> But the code, produced by the compiler, is also the same. So, I think, the debug info also should be the same.
>> 
>>> Also, what happens to the next bit field or variable right after the bit-filed with the now larger container? Is that affected by the patch?
>> 
>> It does not affect the next fields. We point exactly to the bytes, allocated for this particular bitfield only.




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82881/new/

https://reviews.llvm.org/D82881





More information about the llvm-commits mailing list