util/u_trace: Fix usage of variable-sized strings in non-queued case

When tracepoint is not queued, the memory for it is allocated on stack
and no memory is allocated for variable-sized strings. So we shouldn't
copy or print them in non-queued case.

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39128>
This commit is contained in:
Danylo Piliaiev 2026-01-02 16:51:31 +01:00 committed by Marge Bot
parent dc03f94e07
commit 4b9536382c

View file

@ -513,13 +513,13 @@ __attribute__((format(printf, 3, 4))) void ${trace.tp_markers}(struct u_trace_co
static void __emit_label_${trace_name}(struct u_trace_context *utctx, void *cs, struct trace_${trace_name} *entry) {
${trace.tp_markers}(utctx, cs, "${trace_name}("
% for idx,arg in enumerate(trace.tp_print):
% if not arg.is_indirect:
% if not arg.is_indirect and (arg.length_arg is None or arg.length_arg.isdigit()):
"${"," if idx != 0 else ""}${arg.name}=${arg.c_format}"
% endif
% endfor
")"
% for arg in trace.tp_print:
% if not arg.is_indirect:
% if not arg.is_indirect and (arg.length_arg is None or arg.length_arg.isdigit()):
,${arg.value_expr('entry')}
% endif
% endfor
@ -568,8 +568,9 @@ void __trace_${trace_name}(
% endfor
};
% endif
const bool queueing = enabled_traces & U_TRACE_TYPE_REQUIRE_QUEUING;
UNUSED struct trace_${trace_name} *__entry =
enabled_traces & U_TRACE_TYPE_REQUIRE_QUEUING ?
queueing ?
(struct trace_${trace_name} *)u_trace_appendv(ut, ${"cs," if trace.need_cs_param else "NULL,"} &__tp_${trace_name},
0
% for arg in trace.tp_struct:
@ -591,7 +592,10 @@ void __trace_${trace_name}(
% elif arg.length_arg is None:
${arg.copy_func}(__entry->${arg.name}, ${arg.var});
% else:
${arg.copy_func}(__entry->${arg.name}, ${arg.var}, ${arg.length_arg});
% if not arg.length_arg.isdigit():
if (queueing)
% endif
${arg.copy_func}(__entry->${arg.name}, ${arg.var}, ${arg.length_arg});
% endif
% endfor
% if trace.tp_markers is not None: