replay: add tracing events
PATCH 1/1 replay: add tracing events
The replay subsystem does not have any way to see what's going on and how the replay events interleave with other things happening in QEMU.
Add trace events to improve debuggability; to avoid having too many events reimplement all functions in terms of (non-traced) replay_getc and replay_putc and add a single trace event for each datum that is extracted or written.
--- meson.build | 1 + replay/trace.h | 1 + replay/replay-internal.c | 70 ++++++++++++++++++++++++++++++---------- replay/trace-events | 12 +++++++ 4 files changed, 67 insertions(+), 17 deletions(-) create mode 100644 replay/trace.h create mode 100644 replay/trace-events
meson.build +1 -0
@@ -3678,6 +3678,7 @@ if have_system 'hw/gpio', 'migration', 'net', + 'replay', 'system', 'ui', 'hw/remote',
replay/trace.h new file +1 -0
@@ -0,0 +1 @@ +#include "trace/trace-replay.h"
replay/replay-internal.c +53 -17
154 lines not on this page · raw message
replay/trace-events new file +12 -0
@@ -0,0 +1,12 @@ +replay_put_byte(uint8_t event) "%02x" +replay_put_event(uint8_t event) "%02x" +replay_put_word(uint16_t event) "%04x" +replay_put_dword(uint32_t event) "%08x" +replay_put_qword(uint64_t event) "%016" PRIx64 +replay_get_byte(uint8_t byte) "%02x" +replay_get_word(uint16_t word) "%04x" +replay_get_dword(uint32_t dword) "%08x" +replay_get_qword(uint64_t qword) "%016" PRIx64 +replay_fetch_data_kind(void) "" +replay_get_event(uint32_t current, uint8_t data) "#%u data=%02x" +replay_advance_current_icount(uint64_t current_icount, int diff) "current=%" PRIu64 " diff=%d"
Signature · 1 line
2.51.1
PATCH 1/1 replay: add tracing events
--- meson.build | 1 + replay/trace.h | 1 + replay/replay-internal.c | 70 ++++++++++++++++++++++++++++++---------- replay/trace-events | 12 +++++++ 4 files changed, 67 insertions(+), 17 deletions(-) create mode 100644 replay/trace.h create mode 100644 replay/trace-events
meson.build +1 -0
@@ -3678,6 +3678,7 @@ if have_system 'hw/gpio', 'migration', 'net', + 'replay', 'system', 'ui', 'hw/remote',
replay/trace.h new file +1 -0
@@ -0,0 +1 @@ +#include "trace/trace-replay.h"
replay/replay-internal.c +53 -17
154 lines not on this page · raw message
replay/trace-events new file +12 -0
@@ -0,0 +1,12 @@ +replay_put_byte(uint8_t event) "%02x" +replay_put_event(uint8_t event) "%02x" +replay_put_word(uint16_t event) "%04x" +replay_put_dword(uint32_t event) "%08x" +replay_put_qword(uint64_t event) "%016" PRIx64 +replay_get_byte(uint8_t byte) "%02x" +replay_get_word(uint16_t word) "%04x" +replay_get_dword(uint32_t dword) "%08x" +replay_get_qword(uint64_t qword) "%016" PRIx64 +replay_fetch_data_kind(void) "" +replay_get_event(uint32_t current, uint8_t data) "#%u data=%02x" +replay_advance_current_icount(uint64_t current_icount, int diff) "current=%" PRIu64 " diff=%d"
Signature · 1 line
2.51.1
Quoted 21 lines · Paolo Bonzini
The replay subsystem does not have any way to see what's going on and how the replay events interleave with other things happening in QEMU.
Add trace events to improve debuggability; to avoid having too many events reimplement all functions in terms of (non-traced)
replay_getcandreplay_putcand add a single trace event for each datum that is extracted or written.Signed-off-by Paolo Bonzini <[email protected]>--- meson.build | 1 + replay/trace.h | 1 + replay/replay-internal.c | 70 ++++++++++++++++++++++++++++++---------- replay/trace-events | 12 +++++++ 4 files changed, 67 insertions(+), 17 deletions(-)create mode 100644
replay/trace.h
create mode 100644 replay/trace-eventsvoid replay_put_dword(uint32_t dword) {
replay/replay-internal.c void replay_put_byte(uint8_t byte) · line 83
Quoted 6 lines
replay/replay-internal.c +4
-2-replay_put_word (dword >>16 ); -replay_put_word (dword); +int i; + +trace_replay_put_dword (dword); +for (i =24 ; i >=0 ; i -=8 ) {
Matter of taste, this looks more natural to me:
for (i = 32; i > 0; i -= 8) {replay/replay-internal.c void replay_put_byte(uint8_t byte) · line 93
Quoted 12 lines
replay/replay-internal.c +6
-2+replay_putc (dword >> i); + } }void replay_put_qword (int64_t qword) { -replay_put_dword (qword >>32 ); -replay_put_dword (qword); +int i; + +trace_replay_put_qword (qword); +for (i =56 ; i >=0 ; i -=8 ) {
Ditto, etc.
replay/replay-internal.c void replay_put_byte(uint8_t byte) · line 96
Quoted 3 lines
replay/replay-internal.c +2
-0+replay_putc (qword >> i); + } }
Also, still taste, I'd have used trace_replay_{put,get}{8,16,32,64} ;)
Il mer 19 nov 2025, 06:44 Philippe Mathieu-Daudé <[email protected]> ha scritto:
Quoted 29 lines · Paolo Bonzini
Quoted 21 lines
The replay subsystem does not have any way to see what's going on and how the replay events interleave with other things happening in QEMU.
Add trace events to improve debuggability; to avoid having too many events reimplement all functions in terms of (non-traced)
replay_getcandreplay_putcand add a single trace event for each datum that is extracted or written.Signed-off-by Paolo Bonzini <[email protected]>--- meson.build | 1 + replay/trace.h | 1 + replay/replay-internal.c | 70 ++++++++++++++++++++++++++++++---------- replay/trace-events | 12 +++++++ 4 files changed, 67 insertions(+), 17 deletions(-)create mode 100644
replay/trace.h
create mode 100644 replay/trace-eventsvoid replay_put_dword(uint32_t dword) {replay/replay-internal.c void replay_put_byte(uint8_t byte) · line 83
Quoted 6 lines
replay/replay-internal.c +4
-2-replay_put_word (dword >>16 ); -replay_put_word (dword); +int i; + +trace_replay_put_dword (dword); +for (i =24 ; i >=0 ; i -=8 ) {
Quoted 4 lines
Matter of taste, this looks more natural to me:
for (i = 32; i > 0; i -= 8) {
But ">> (i - 8)" is uglier... Or you have to put i -= 8 in the loop body.
Paolo
Quoted 24 lines
replay/replay-internal.c void replay_put_byte(uint8_t byte) · line 93
Quoted 12 lines
replay/replay-internal.c +6
-2+replay_putc (dword >> i); + } }void replay_put_qword (int64_t qword) { -replay_put_dword (qword >>32 ); -replay_put_dword (qword); +int i; + +trace_replay_put_qword (qword); +for (i =56 ; i >=0 ; i -=8 ) {Ditto, etc.
replay/replay-internal.c void replay_put_byte(uint8_t byte) · line 96
Quoted 3 lines
replay/replay-internal.c +2
-0+replay_putc (qword >> i); + } }Reviewed-by Philippe Mathieu-Daudé <[email protected]>Also, still taste, I'd have used trace_replay_{put,get}{8,16,32,64} ;)