diff --git a/libweston/surface-state.c b/libweston/surface-state.c index a05496887..c1dc3ac29 100644 --- a/libweston/surface-state.c +++ b/libweston/surface-state.c @@ -206,11 +206,11 @@ weston_surface_attach(struct weston_surface *surface, WESTON_TRACE_BEGIN_ANNOTATION(); if (buffer) { - WESTON_TRACE_ANNOTATE_ADD("surface", surface->internal_name); - WESTON_TRACE_ANNOTATE_ADD("format", buffer->pixel_format->drm_format_name); - WESTON_TRACE_ANNOTATE_ADD("modifier", buffer->format_modifier_name); - WESTON_TRACE_ANNOTATE_ADD("width", buffer->width); - WESTON_TRACE_ANNOTATE_ADD("height", buffer->height); + WESTON_TRACE_ANNOTATE(("surface", surface->internal_name), + ("format", buffer->pixel_format->drm_format_name), + ("modifier", buffer->format_modifier_name), + ("width", buffer->width), + ("height", buffer->height)); } WESTON_TRACE_ANNOTATE_FUNC_FLOW(&surface->flow_id); diff --git a/libweston/weston-trace.h b/libweston/weston-trace.h index 49c207725..9aa78576f 100644 --- a/libweston/weston-trace.h +++ b/libweston/weston-trace.h @@ -77,7 +77,7 @@ struct weston_debug_annotation __pd_annots[WESTON_MAX_DEBUG_ANNOTS]; \ unsigned int __pd_i = 0 -#define _WESTON_TRACE_ANNOTATE_ADD(k, v) \ +#define _WESTON_TRACE_DO_ANNOTATE_ADD(k, v) \ weston_assert_u32_gt(NULL, WESTON_MAX_DEBUG_ANNOTS, __pd_i); \ _Generic((v), \ int: perfetto_annotate_int, \ @@ -230,7 +230,7 @@ _weston_trace_scope_end(int *scope) #define _WESTON_TRACE_BEGIN_ANNOTATION() #define _WESTON_TRACE_COMMIT_ANNOTATION(id, name) -#define _WESTON_TRACE_ANNOTATE_ADD(k, v) +#define _WESTON_TRACE_DO_ANNOTATE_ADD(k, v) #define _WESTON_TRACE_ANNOTATE_FUNC() #define _WESTON_TRACE_ANNOTATE_FUNC_FLOW(id, name) @@ -249,8 +249,8 @@ _weston_trace_scope_end(int *scope) #define WESTON_TRACE_BEGIN_ANNOTATION() \ _WESTON_TRACE_BEGIN_ANNOTATION() -#define WESTON_TRACE_ANNOTATE_ADD(k, v) \ - _WESTON_TRACE_ANNOTATE_ADD(k, v) +#define WESTON_TRACE_DO_ANNOTATE_ADD(k, v) \ + _WESTON_TRACE_DO_ANNOTATE_ADD(k, v) #define WESTON_TRACE_COMMIT_ANNOTATION(id) \ _WESTON_TRACE_COMMIT_ANNOTATION(id, __func__) @@ -261,4 +261,21 @@ _weston_trace_scope_end(int *scope) #define WESTON_TRACE_ANNOTATE_FUNC_FLOW(id) \ _WESTON_TRACE_ANNOTATE_FUNC_FLOW(id, __func__) +#define FORCE_RECURSE () +#define WESTON_TRACE_ANNOTATE_ADD(k, v) WESTON_TRACE_DO_ANNOTATE_ADD(k, v) +#define WESTON_TRACE_ANNOTATE_PAIR(pair) WESTON_TRACE_ANNOTATE_ADD pair + +/* There is a large but finite limit to the number of options */ +#define EXPAND(arg) EXPAND1(EXPAND1(EXPAND1(EXPAND1(arg)))) +#define EXPAND1(arg) EXPAND2(EXPAND2(EXPAND2(EXPAND2(arg)))) +#define EXPAND2(arg) arg + +#define ITER_HELPER(operation, pair, ...) \ + operation(pair) \ + __VA_OPT__(ITER_AGAIN FORCE_RECURSE (operation, __VA_ARGS__)) +#define ITER_AGAIN() ITER_HELPER + +#define WESTON_TRACE_ANNOTATE(...) \ + __VA_OPT__(EXPAND(ITER_HELPER(WESTON_TRACE_ANNOTATE_PAIR, __VA_ARGS__))) + #endif /* WESTON_TRACE_H */