[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 11:36:16 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
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




More information about the lldb-commits mailing list