Source Locations¶
-
class
gccjit
::
location
¶ A gccjit::location encapsulates a source code location, so that you can (optionally) associate locations in your language with statements in the JIT-compiled code, allowing the debugger to single-step through your language.
gccjit::location instances are optional: you can always omit them from any C++ API entrypoint accepting one.
You can construct them using
gccjit::context::new_location()
.You need to enable
GCC_JIT_BOOL_OPTION_DEBUGINFO
on thegccjit::context
for these locations to actually be usable by the debugger:ctxt.set_bool_option (GCC_JIT_BOOL_OPTION_DEBUGINFO, 1);
-
gccjit::location
gccjit::context
::
new_location
(const char *filename, int line, int column)¶ Create a gccjit::location instance representing the given source location.
Faking it¶
If you don’t have source code for your internal representation, but need
to debug, you can generate a C-like representation of the functions in
your context using gccjit::context::dump_to_file()
:
ctxt.dump_to_file ("/tmp/something.c",
1 /* update_locations */);
This will dump C-like code to the given path. If the update_locations argument is true, this will also set up gccjit::location information throughout the context, pointing at the dump file as if it were a source file, giving you something you can step through in the debugger.