[Lldb-commits] [PATCH] D85376: Fix how ValueObjectChild handles bit-fields stored in a Scalar in UpdateValue()

Shafik Yaghmour via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Aug 6 12:21:35 PDT 2020


shafik added inline comments.


================
Comment at: lldb/source/Core/ValueObjectChild.cpp:202-205
-            if (m_bitfield_bit_size)
-              scalar.ExtractBitfield(m_bitfield_bit_size,
-                                     m_bitfield_bit_offset);
-            else
----------------
shafik wrote:
> friss wrote:
> > shafik wrote:
> > > friss wrote:
> > > > Why remove the code in `ValueObject` rather than avoid re-extracting at printing time? I'm not sure which one is correct. If you get your hands on a `ValueObject` for the field in your test, what will `GetValueAsUnsigned` return? it should give the correct field value.
> > > `lldb_private::DumpDataExtractor(…)` is general purpose and it used by a lot of other code, it does know the value comes from a `Scalar` or otherwise it is just receiving a `DataExtractor` and obtaining the data from there. 
> > You didn't answer the most important question. Will `GetValueAsUnsigned` return the correct value on such a ValueObject once you remove this code?
> apologies, misunderstood.
> 
> Yes, it does:
> 
> ```
> (lldb) script var = lldb.frame.FindVariable("u")
> (lldb) script print(var.GetChildMemberWithName('raw'))
> (uint32_t) raw = 1688469761
> (lldb) script print(var.GetChildMemberWithName('a'))
> (uint32_t:8) a = 1
> (lldb) script print(var.GetChildMemberWithName('b'))
> (uint32_t:8) b = 1
> (lldb) script print(var.GetChildMemberWithName('c'))
> (uint32_t:6) c = 36
> (lldb) script print(var.GetChildMemberWithName('d'))
> (uint32_t:2) d = 2
> (lldb) script print(var.GetChildMemberWithName('e'))
> (uint32_t:6) e = 36
> (lldb) script print(var.GetChildMemberWithName('f'))
> (uint32_t:2) f = 1
> 
> ```
Whoops, copy-pasta:

```
(lldb) script print(var.GetChildMemberWithName('raw').GetValueAsUnsigned())
1688469761
(lldb) script print(var.GetChildMemberWithName('a').GetValueAsUnsigned())
1
(lldb) script print(var.GetChildMemberWithName('b').GetValueAsUnsigned())
1
(lldb) script print(var.GetChildMemberWithName('c').GetValueAsUnsigned())
36
(lldb) script print(var.GetChildMemberWithName('d').GetValueAsUnsigned())
2
(lldb) script print(var.GetChildMemberWithName('e').GetValueAsUnsigned())
36
(lldb) script print(var.GetChildMemberWithName('f').GetValueAsUnsigned())
1
```


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

https://reviews.llvm.org/D85376



More information about the lldb-commits mailing list