[Compile] Inserting compiled code via jumps

Tom Tromey tom@tromey.com
Sat Dec 15 22:54:00 GMT 2018

>>>>> "Paul" == Paul Naert <paul.naert@polymtl.ca> writes:

Paul> I am a masters student and I would like to devote my research to
Paul> improving GDB's GCC Compile and Execute by adding the possibility to
Paul> jump directly to the compiled code without having to hit a breakpoint.

Paul> The idea is to reuse the same principle that was used in fast
Paul> tracepoints to insert code in a compiled program, except that instead
Paul> of jumping to GDB's collector function we would execute the code
Paul> compiled by GCC each time we hit the selected instruction.

I am not sure I really understand the idea.

With the "compile" command, we had hopes of someday extending it to
either allow fast breakpoint conditions (by compiling the breakpoint
condition and patching the process); or to allow fix-and-continue
(recompiling a single function and inserting it).

Is your idea like one of these?  If it's different, could you maybe show
an example of how a user would use it?

Paul>    -  Has someone already worked on this ? On the wiki page there are
Paul> mentions to future projects that seem related (fast breakpoint
Paul> conditions most notably)

As far as I know nobody is working on it.

Paul>    -  Do you see any reason why that would not work that I missed,
Paul> except for the limitations of the existing Compile project?

I think it's entirely possible.  I think the main issues involve the
patching -- figuring out how to replace instructions.  Maybe dyninst
could be used to help with the rewriting, or maybe it can be done purely
in gdb.


More information about the Gdb mailing list