gdb: add 'maintenance print record-instruction' command
authorBruno Larsen <blarsen@redhat.com>
Thu, 3 Nov 2022 09:17:36 +0000 (10:17 +0100)
committerBruno Larsen <blarsen@redhat.com>
Wed, 4 Jan 2023 10:21:57 +0000 (11:21 +0100)
commite24d337e219da287535eddc5c9918ac410d124be
treeb13e90469ebd1690ffeb755eb1ccaab6471d2a60
parent502c7218da3c486e58d6ce039b36fb4fa62d3a92
gdb: add 'maintenance print record-instruction' command

While chasing some reverse debugging bugs, I found myself wondering what
was recorded by GDB to undo and redo a certain instruction. This commit
implements a simple way of printing that information.

If there isn't enough history to print the desired instruction (such as
when the user hasn't started recording yet or when they request 2
instructions back but only 1 was recorded), GDB warns the user like so:

(gdb) maint print record-instruction
Not enough recorded history

If there is enough, GDB prints the instruction like so:

(gdb) maint print record-instruction
4 bytes of memory at address 0x00007fffffffd5dc changed from: 01 00 00 00
Register eflags changed: [ IF ]
Register rip changed: (void (*)()) 0x401115 <main+15>

Approved-by: Eli Zaretskii <eliz@gnu.org>
Reviewed-by: Alexandra Hajkova <ahajkova@redhat.com>
Reviewed-by: Lancelot Six <lsix@lancelotsix.com>
Approved-by: Tom Tromey <tom@tromey.com>
gdb/NEWS
gdb/doc/gdb.texinfo
gdb/record-full.c
gdb/testsuite/gdb.reverse/maint-print-instruction.c [new file with mode: 0644]
gdb/testsuite/gdb.reverse/maint-print-instruction.exp [new file with mode: 0644]