class ConstValue
Defined at line 31 of file ../../src/developer/debug/zxdb/symbols/const_value.h
Representation used for Values (DataMembers and Variables) that have a constant value. These
members have no in-memory storage.
The encoding for const values is complicated which necessitates this class. The storage
represents "whatever the value looks like in memory".
In practice, our Clang outputs:
- DW_FORM_sdata / DW_FORM_udata for normal signed and unsigned numbers. In this case we don't
know the size of the output without doing lots more work.
- DW_FORM_block* for other stuff. We assume the size is correct in this case.
We choose not to be very smart about how to store integer data. Theoretically, the types might
not be completely known when decoding a variable. There might be forward-defined types that need
the symbol index, and resolving things like typedefs can be complicated. We choose to punt that
to a higher layer and only store the data here with minimal semantic knowledge. Numbers come
out of LLVM's decoder as 64-bit integers so this is what we handle. Anything larger than this
must be expressed as a "block" and have the correct size.
Public Methods
void ConstValue (int64_t v)
Use for numbers. For unsigned numbers, cast to a signed value. The bytes will be copied out of
this value from the low byte and as long as it's sign extended when necessary the results will
be correct for unsigned and signed numbers.
Defined at line 12 of file ../../src/developer/debug/zxdb/symbols/const_value.cc
void ConstValue (std::vector<uint8_t> buffer)
Use for arbitrary data.
Defined at line 17 of file ../../src/developer/debug/zxdb/symbols/const_value.cc
std::vector<uint8_t> GetConstValue (size_t byte_count)
Copies the const value out to a memory buffer of the requested size.
This will assert if !has_value().
If the requested size is smaller than the data we have, the data will be truncated. Since we
assume little-endian, this will do the right thing for numbers
<
64 bits. If the requested
size is larger, it will be 0-filled on the right. This behavior is because const values are
normally used just for integers and its difficult to know the correct size when the attribute
is being decoded.
(If we need to support big endian we probably want to mark the "number" case in the constructor
so we know how to truncate in this function).
Defined at line 19 of file ../../src/developer/debug/zxdb/symbols/const_value.cc
void ConstValue ()
Initializes has having no const value.
Defined at line 34 of file ../../src/developer/debug/zxdb/symbols/const_value.h
bool has_value ()
Returns whether this holds a value. When this returns false, the associated value (normally the
one that "this" is a member of) has no "const value" and it refers to a real variable in
memory.
Defined at line 47 of file ../../src/developer/debug/zxdb/symbols/const_value.h