I loaded up a C library in gdb, started the built-in Python interpreter, and ran
import gdb
t = gdb.lookup_type('Some::Type')
field = t.fields()[0]
print(field.bitpos)
print(field.bitsize)
The output is
0
0
What does it mean for a field to have a size of 0?
I've run gdb.lookup_type
on the class of the field and it's not empty. I think it's a virtual class because all it has is a vtable.
CodePudding user response:
bitsize
is only meaningful for bit fields or packed fields. For regular fields, the size is given by the type. Use
t.fields()[0].type.sizeof
to access the size.