Library for Dwarf-based reflection in C
Reflection (librefl) is a C library for run-time reflection,
i.e. working with objects of the program from within that program
itself (like what you have in any high-level language). It works by
interpreting Dwarf debugging information stored at the binary itself.
It uses libelf, libdw and libdwfl of elfutils to read the Dwarf data
and libffi to invoke functions.
The library is currently in very early stage of development that I
call a “weekend hack”, or more euphemistically, “proof of the
concept”. It’s not even a “work in progress,” because, well, it was a
“weekend hack”. That aside, here are some examples of use:
https://github.com/pmachata/reflection/blob/HEAD/userefl.c
https://github.com/pmachata/reflection/blob/HEAD/userefl.cc
Note that there is no way to learn what an arbitrary void* points to.
Heap objects are not described at runtime in any way.