Standard AuxData Schemata
The AuxData class provides generic storage for application-specific data. This allows data to be attached to either the IR or Module classes in GTIRB.
We specify a small number of standard gtirb::AuxData schemata to support interoperability. These are listed below, in two sets:
- Sanctioned Recommended for GTIRB users. Individual schemata are unlikely to change in future, although the set of Sanctioned schemata may grow.
- Provisional Under consideration for 'sanctioned' status.
For example, if you want to store alignment requirements for blocks and data objects, you can use an alignment table.
namespace schema {
struct MyAuxDataFoo {
static constexpr const char* Name = "foo";
typedef Foo Type;
};
}
}
using namespace schema;
void call_me_from_main()
{
AuxDataContainer::registerAuxDataType<Alignment>();
AuxDataContainer::registerAuxDataType<MyAuxDataFoo>();
}
void do_stuff_with_gtirb()
{
Context C;
Module& module = *ir.modules_begin();
module.addAuxData<Alignment>(std::map<UUID, uint64_t>{});
Section* section = module.addSection(C, ".text");
ByteInterval* interval = section->addByteInterval(C, Addr(400), 1000);
CodeBlock* b1 = interval->addBlock<CodeBlock>(C, 64, 6);
auto* align_map = module.getAuxData<Alignment>();
if (align_map)
(*align_map)[b1->getUUID()] = 8;
Foo my_foo = BuildAFoo();
module.addAuxData<MyAuxDataFoo>(std::move(my_foo));
module.getAuxData<MyAuxDataFoo>()->some_member_function();
}
static IR * Create(Context &C)
static Module * Create(Context &C, const std::string &Name)
Sanctioned AuxData Tables
The following are the sanctioned AuxData table schemata.
functionBlocks
functionEntries
| |
Label | "functionEntries" |
Type | std::map<gtirb::UUID, std::set<gtirb::UUID>> |
Key | Function UUID. |
Value | The set of UUIDs of all the entry blocks (gtirb::CodeBlock) for the function. |
AttachedTo | Module |
functionNames
| |
Label | "functionNames" |
Type | std::map<gtirb::UUID, gtirb::UUID> |
Key | Function UUID. |
Value | The UUID of a Symbol whose name field contains the name of the function. |
AttachedTo | Module |
types
| |
Label | "types" |
Type | std::map<gtirb::UUID,std::string> |
Key | The gtirb::UUID of a gtirb::DataBlock. |
Value | The type of the data, expressed as a std::string containing a C++ type specifier. |
AttachedTo | Module |
alignment
comments
| |
Label | "comments" |
Type | std::map<gtirb::Offset, std::string> |
Key | The gtirb::Offset of a comment. |
Value | A comment string relevant to the specified offset in the specified GTIRB entry. |
AttachedTo | Module |
symbolForwarding
padding
| |
Label | "padding" |
Type | std::map<gtirb::Addr, uint64_t> |
Key | An address at which padding has been inserted. |
Value | The length of the padding, in bytes. |
AttachedTo | Module |
Provisional AuxData Tables
There are currently no provisional table schemata.