I have code in a domain-specific language (DSL). Files in this language are translated into C source code files, which are then compiled into binaries by a usual compiler toolchain (GCC):
DSL file --> C file --> Object file --> binary file
I want to measure test coverage for code written in this DSL. The language lacks native tooling support for measuring test coverage. However, I can use traditional GCC tools such as gcov and compiler's --coverage flags (or Clang equivalents) to instrument the generated binaries. The intermediate C-representation can then be annotated with coverage information.
DSL file --> C file --> Instrumented object file --> instrumented binary file --> coverage database
↕ |
annotated C file <-----------------------------------------------------------+
The problem is, the intermediate C-code does not precisely map to its DSL input: symbols may be renamed, methods moved around, lines added and removed etc.
It is quite hard to mentally map the source code lines back and forth.
Is there a way to trace back collected coverage information to associate it with the original DSL code?