Browsing through peda's source, it seems to use a gdb hook-stop, which can be modified back and forth:
gdb-peda$ show user hook-stop
User command "hook-stop":
peda context
session autosave
gdb-peda$ define hook-stop
Type commands for definition of "hook-stop".
End with a line saying just "end".
>session autosave
>end
gdb-peda$ n
18 printf("...");
gdb-peda$ define hook-stop
Type commands for definition of "hook-stop".
End with a line saying just "end".
>peda context
>session autosave
>end
gdb-peda$ n
[---registers---]
EAX: 0x0
EBX: 0x56557000 --> 0x1ef8
Relevant source is at https://github.com/longld/peda/blob/84d38bda505941ba823db7f6c1bcca1e485a2d43/peda.py#L6120 and https://github.com/longld/peda/blob/84d38bda505941ba823db7f6c1bcca1e485a2d43/peda.py#L230 .
I'd imagine there's a way to extend peda, so that the peda
object's methods can be called, but I can't figure that out. In the absence of that, we can invoke those commands manually. Note that gdb doesn't seem to allow nested define
s, so we can't script the (re)define
s themselves.