[Lldb-commits] [PATCH] D138197: [lldb] Fix bitfield incorrectly printing when field crosses a storage unit

LU Hongyi via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sun Mar 26 10:04:02 PDT 2023


jwnhy added a comment.

Hi, guys, I have met this issue #61706 <https://github.com/llvm/llvm-project/issues/61706>.

The case I provided shows that even without DWARF v2, this problem still exists.

I wonder if such modification is really needed or not.

Also, I am not sure changing all these to `int` actually fixes the issue here.

In fact, in `UpdateValue`, the `m_byte_offset` also changed by the `overhang_bytes` in line .
For a bitfield not aligned to `*type_bit_size`, moving `overhang_bytes` will cause truncation in the bitfield.

  #pragma pack(1)
  struct  {
    signed f0 : 27;
    unsigned f5 : 30;
  } g_96 = {5070, 1795821};
  int main() {return 0;}

The structure in memory is represented as `0xdb37680013ce`, adding `m_byte_offset` with `overhang_bytes` results in `0xdb37`, with last five bits lost.

This patchset may fix the underflow problem of `m_bitfield_bit_offset`, but does not fix the truncation issue...

Not knowing there is a WIP patch, I have created another smaller patch, which just checks... (if it's not ok to hijack the thread, plz tell me...I am really newbie...)
https://reviews.llvm.org/D146919

I wonder if it's ok I take over this issue?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138197



More information about the lldb-commits mailing list