INNER CODE UNIT · Python
__init__
SpartanJ/eepp · projects/scripts/debug/eepp_gdb.py:7
def __init__(self, val):
self.val = val
# Get the underlying uint8_t array
self.m_data = self.val["m_data"]["_M_elems"]
self.type_t = self.val.type.template_argument(0)
def is_direct(self):
# bit 0 of the first byte is the discriminator
return (int(self.m_data[0]) & 1) != 0
def to_string(self):
if self.is_direct():
size = int(self.m_data[0]) >> 1
return f"EE::SmallVector<{self.type_t}> [Direct] (size={size})"
else:
# For indirect, we have to fetch the pointer from m_data
void_ptr = self.m_data.address.cast(
gdb.lookup_type("void").pointer().pointer()