GDB has a reasonably robust API which is exposed to Python at runtime. It allows for inspecting various types, but does not appear to allow creation of types.
However, types can be manually added by loading an object file at runtime (https://stackoverflow.com/q/7272558).
Is there any way to add or create a new
gdb.Type object at runtime?
The intent is to then allow inspection of memory via
gdb.Value.cast to the
type.pointer() and then
.dereference()d. This would be much better/easier than manually deserializing data field-by-field.
Alternatively, I thought that I could just load an object file programmatically. It looks like GDB is perfectly happy to load cross-architecture object files for symbol/type purposes. In order to not kill any real/useful symbols, or create misleading ones, a non-existent address should be used. However, loading a
.o at an unmapped address requires the user to verify (type
y), so when done from
gdb.execute(...) it fails outright.