The compile command works by issuing a new function, compiling it with gcc, and then calling the function from gdb ("calling incomplete functions" in gdb lingo).
The code generator has some special functions that allow you to access local variables. In particular, it converts DWARF location expressions to C. Register references are translated into field references in a special struct . gdb organizes copying the appropriate registers to an instance of this structure when making a lower call. At the end of the call, it copies the registers back - this allows you to write local variables.
This description should, I think, clarify what will work and what will not. I would expect return and other flow control operations ( break , continue , goto ) to not work.
Writing to a register should work, but only for registers, which are necessary for some expression of location. Perhaps this can be fixed; although I believe that now, for performance reasons, only the necessary registers are transferred.
I don't know what will happen if your compiled code calls longjmp or throw (well, when C ++ is implemented). Probably crazy.
One thing worth knowing is that this code was designed so that a future patch could add compiled breakpoint conditions, perhaps in combination with something like dyninst.
Tom tromey
source share