class DataMember
Defined at line 17 of file ../../src/developer/debug/zxdb/symbols/data_member.h
Represents a data member in a class. Not to be confused with function parameters and local
variables which are represented by a Variable.
The type and name come from the Value base class.
Public Methods
uint32_t member_location ()
The byte offset from the containing class or struct of this data member. This is only valid
if !is_external() and data_bit_offset is not set -- see the base class' Value::is_external().
Defined at line 23 of file ../../src/developer/debug/zxdb/symbols/data_member.h
void set_member_location (uint32_t m)
Defined at line 24 of file ../../src/developer/debug/zxdb/symbols/data_member.h
bool is_bitfield ()
Defined at line 26 of file ../../src/developer/debug/zxdb/symbols/data_member.h
uint32_t data_bit_offset ()
The DW_AT_data_bit_offset is used in DWARF 4 to indicate the bit position of a member bitfield.
Unlike bit_offset, this will measure from the beginning of the containing structure.
If data_bit_offset is set, then member_location, byte_size, and bit_offset will not be set.
Defined at line 32 of file ../../src/developer/debug/zxdb/symbols/data_member.h
void set_data_bit_offset (uint32_t dbo)
Defined at line 33 of file ../../src/developer/debug/zxdb/symbols/data_member.h
uint32_t byte_size ()
The DW_AT_byte_size attribute on the data member. It won't be set if data_bit_offset is set.
Normally the byte size will be 0 which means to take the size from the type. For bitfields
this will indicate the size of the larger field containing the bitfield, and the bit_offset
will count from the high bit inside this byte_size (where byte_size is read as little-endian
on little-endian machines).
As of this writing I've only ever seen GCC and Clang generated byte_size() that matches the
type().byte_size() even when the actual data occupies more physical bytes than the size of
the type (because it's not aligned). This case will generated negative bit offsets.
Note that for bitfields reading this many bytes may read off the end of the structure. For
example:
struct MyStruct {
long long data : 2;
};
MyStruct will have a byte_size of 1, while MyStruct.data will have a byte_size of 8! The bit
offset will select the value bits from the structure.
Defined at line 55 of file ../../src/developer/debug/zxdb/symbols/data_member.h
void set_byte_size (uint32_t bs)
Defined at line 56 of file ../../src/developer/debug/zxdb/symbols/data_member.h
int32_t bit_offset ()
Bit offset from the member_location(). This is counting from the high bit of the byte_size().
When that many bytes is read into memory (swapping the byte order for little-endian).
As an example, a little-endian "int foo : 3;" might be defined as having:
- byte_size = 4
- bit_offset = 29
- bit_size = 3
- data_bit_offset = 0
Bit layout (stored in the low 3 bits of a 32-bit integer):
Byte 0 (low) Byte 1 Byte 2 Byte 3 (high bits)
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
x x x
It can be negative which means it starts *beyond* the byte_size(). I have not seen this be
more than one byte extra since otherwise the address will likely be one greater. For example:
struct {
// member_location = 0
// byte_size = 1
// bit_size = 6
// bit_offset = 2
// data_bit_offset = 0
bool a : 6;
// member_location = 0
// byte_size = 1
// bit_size = 7
// bit_offset = -5
// data_bit_offset = 6
bool b : 7;
};
Bit layout:
Byte 0 Byte 1
7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0
b b a a a a a a b b b b b
^ -5 bits in little-endian from the high bit of byte 0.
Defined at line 98 of file ../../src/developer/debug/zxdb/symbols/data_member.h
void set_bit_offset (int32_t bo)
Defined at line 99 of file ../../src/developer/debug/zxdb/symbols/data_member.h
uint32_t bit_size ()
Number of bits that count. 0 means all.
Defined at line 102 of file ../../src/developer/debug/zxdb/symbols/data_member.h
void set_bit_size (uint32_t bs)
Defined at line 103 of file ../../src/developer/debug/zxdb/symbols/data_member.h
const FileLine & decl_line ()
The location of the declaration, used by Rust generators.
Defined at line 106 of file ../../src/developer/debug/zxdb/symbols/data_member.h
void set_decl_line (FileLine decl)
Defined at line 107 of file ../../src/developer/debug/zxdb/symbols/data_member.h
Protected Methods
const DataMember * AsDataMember ()
Symbol protected overrides.
Defined at line 16 of file ../../src/developer/debug/zxdb/symbols/data_member.cc
Friends
class MakeRefCountedHelper
class RefCountedThreadSafe