[RFC][PATCH 0/7] Patching new code in a binary

Tom Tromey tom@tromey.com
Fri May 22 19:57:10 GMT 2020


>>>>> ">" == paul-naert via Gdb-patches <gdb-patches@sourceware.org> writes:

>> I'm looking for input on a series of patches that I wrote to extend
>> the compile command. At the moment, this commands lets the user type
>> in C/C++ code that is compiled by GCC and then executed in the
>> context of the program.

This is fantastic.

>> If there is interest in the commands, I will work on the
>> documentation and test cases.

Yes, please.  I think this is very interesting work.

>> - Red zone handling. This complicates the trampoline. I believe that
>> this issue was fixed by the manipulation I did in the trampoline, but
>> this seems to be absent from the GDB tracepoints. Is there something
>> I missed or is this a bug of fast tracepoints?

I don't know, sorry.

>> - Since we save and restore all registers, some instrumentation code
>> may not be able to properly modify variable values.

The original idea in the compile approach was that the code could write
into the structure-of-register-values, and then on return these values
would be loaded back into the registers.  So, in patch 7, this could be
done after calling the patched function, but before executing the
displaced instruction.

>> If the community is interested in this functionnality, I have also
>> worked on making it more usable by getting rid of the 5 byte
>> limitation using instruction punning. This series of patches works,
>> but is not compliant yet with the GDB standards.

I didn't go through and mention the coding style stuff, but there's a
fair amount of changes to be done there.  Also ChangeLogs are required
for a final patch.

I think this is very promising, though.

One related thing I'm interested in is extending this to compile
breakpoint conditions.

Tom


More information about the Gdb-patches mailing list