Registering Code (Debugging with GDB)
From Get docs
Gdb/docs/latest/gdb/Registering-Code
Next: Unregistering Code, Previous: Declarations, Up: JIT Interface [Contents][Index]
29.2 Registering Code
To register code with GDB, the JIT should follow this protocol:
- Generate an object file in memory with symbols and other desired debug information. The file must include the virtual addresses of the sections.
- Create a code entry for the file, which gives the start and size of the symbol file.
- Add it to the linked list in the JIT descriptor.
- Point the relevant_entry field of the descriptor at the entry.
- Set
action_flag
toJIT_REGISTER
and call__jit_debug_register_code
.
When GDB is attached and the breakpoint fires, GDB uses the relevant_entry
pointer so it doesn’t have to walk the list looking for new code. However, the linked list must still be maintained in order to allow GDB to attach to a running process and still find the symbol files.