From c56f2bc7091d720bde09a19b268be20f8122a705 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Tue, 5 May 2026 12:48:52 -0500 Subject: [PATCH] trace: Have annotation functions return a count This is a step towards annotating larger structs. Signed-off-by: Derek Foreman --- libweston/perfetto/u_perfetto.cc | 12 +++++++++--- libweston/perfetto/u_perfetto.h | 6 +++--- libweston/weston-trace.h | 5 ++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/libweston/perfetto/u_perfetto.cc b/libweston/perfetto/u_perfetto.cc index 76b6921cf..40800c2d2 100644 --- a/libweston/perfetto/u_perfetto.cc +++ b/libweston/perfetto/u_perfetto.cc @@ -227,7 +227,7 @@ util_perfetto_trace_commit_annotate_func_flow(uint64_t id, const char *name, }); } -void +int perfetto_annotate_int(struct weston_debug_annotation *annots, unsigned int count, const char *key, @@ -236,9 +236,11 @@ perfetto_annotate_int(struct weston_debug_annotation *annots, annots[count].type = WESTON_DEBUG_ANNOTATION_INT_VAL; annots[count].ivalue = value; annots[count].key = key; + + return 1; } -void +int perfetto_annotate_float(struct weston_debug_annotation *annots, unsigned int count, const char *key, @@ -247,9 +249,11 @@ perfetto_annotate_float(struct weston_debug_annotation *annots, annots[count].type = WESTON_DEBUG_ANNOTATION_FLOAT_VAL; annots[count].fvalue = value; annots[count].key = key; + + return 1; } -void +int perfetto_annotate_string(struct weston_debug_annotation *annots, unsigned int count, const char *key, @@ -258,6 +262,8 @@ perfetto_annotate_string(struct weston_debug_annotation *annots, annots[count].type = WESTON_DEBUG_ANNOTATION_STR_VAL; annots[count].svalue = value; annots[count].key = key; + + return 1; } class UtilPerfettoObserver : public perfetto::TrackEventSessionObserver { diff --git a/libweston/perfetto/u_perfetto.h b/libweston/perfetto/u_perfetto.h index cb1234285..00570f615 100644 --- a/libweston/perfetto/u_perfetto.h +++ b/libweston/perfetto/u_perfetto.h @@ -92,19 +92,19 @@ uint64_t util_perfetto_next_id(void); uint64_t util_perfetto_new_track(const char *name); -void +int perfetto_annotate_int(struct weston_debug_annotation *annots, unsigned int count, const char *key, int value); -void +int perfetto_annotate_float(struct weston_debug_annotation *annots, unsigned int count, const char *key, float value); -void +int perfetto_annotate_string(struct weston_debug_annotation *annots, unsigned int count, const char *key, diff --git a/libweston/weston-trace.h b/libweston/weston-trace.h index 9aa78576f..9d4b55979 100644 --- a/libweston/weston-trace.h +++ b/libweston/weston-trace.h @@ -79,14 +79,13 @@ #define _WESTON_TRACE_DO_ANNOTATE_ADD(k, v) \ weston_assert_u32_gt(NULL, WESTON_MAX_DEBUG_ANNOTS, __pd_i); \ - _Generic((v), \ + __pd_i += _Generic((v), \ int: perfetto_annotate_int, \ unsigned int: perfetto_annotate_int, \ float: perfetto_annotate_float, \ char *: perfetto_annotate_string, \ const char *: perfetto_annotate_string \ - ) (__pd_annots, __pd_i, k, v); \ - __pd_i++; + ) (__pd_annots, __pd_i, k, v); #define _WESTON_TRACE_COMMIT_ANNOTATION(id, name) \ do { \