From 7791b5286cb763eae8d77db1ac710609252cbc0a Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Mon, 16 Jun 2025 14:26:54 -0400 Subject: [PATCH] util/u_trace: Add u_trace_move() Destructively copy trace contents to another trace, transfering ownership of resources. This will be useful for turnip. Part-of: --- src/util/perf/u_trace.c | 10 ++++++++++ src/util/perf/u_trace.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/util/perf/u_trace.c b/src/util/perf/u_trace.c index 17f3544d1d2..88be14fbd01 100644 --- a/src/util/perf/u_trace.c +++ b/src/util/perf/u_trace.c @@ -793,6 +793,16 @@ u_trace_init(struct u_trace *ut, struct u_trace_context *utctx) list_inithead(&ut->trace_chunks); } +void +u_trace_move(struct u_trace *dst, struct u_trace *src) +{ + dst->utctx = src->utctx; + list_replace(&src->trace_chunks, &dst->trace_chunks); + dst->num_traces = src->num_traces; + src->num_traces = 0; + list_delinit(&src->trace_chunks); +} + void u_trace_fini(struct u_trace *ut) { diff --git a/src/util/perf/u_trace.h b/src/util/perf/u_trace.h index 8ca0d617982..9b3111cbc7f 100644 --- a/src/util/perf/u_trace.h +++ b/src/util/perf/u_trace.h @@ -300,6 +300,7 @@ void u_trace_context_fini(struct u_trace_context *utctx); void u_trace_context_process(struct u_trace_context *utctx, bool eof); void u_trace_init(struct u_trace *ut, struct u_trace_context *utctx); +void u_trace_move(struct u_trace *dst, struct u_trace *src); void u_trace_fini(struct u_trace *ut); void u_trace_state_init(void);