mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-22 18:18:16 +02:00
trace: Put annotations in a separate file
For now just the three we have, but we'll be adding a bunch of complex annotations, so having their own place will be cleaner. Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
This commit is contained in:
parent
6748ed6b57
commit
f5f6989a65
6 changed files with 119 additions and 57 deletions
|
|
@ -117,6 +117,8 @@ endif
|
|||
|
||||
if get_option('perfetto')
|
||||
srcs_libweston += [
|
||||
'perfetto/annotations.c',
|
||||
'perfetto/annotations.h',
|
||||
'perfetto/u_perfetto.cc',
|
||||
'perfetto/u_perfetto.h',
|
||||
'timeline-perfetto.c'
|
||||
|
|
|
|||
71
libweston/perfetto/annotations.c
Normal file
71
libweston/perfetto/annotations.c
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Copyright (C) 2026 Amazon.com, Inc. or its affiliates
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <libweston/libweston.h>
|
||||
|
||||
#include "perfetto/annotations.h"
|
||||
#include "weston-trace.h"
|
||||
|
||||
WL_EXPORT void
|
||||
perfetto_annotate_int(struct weston_debug_annotations *annots,
|
||||
const char *key,
|
||||
int value)
|
||||
{
|
||||
struct weston_debug_annotation *annot = &annots->annots[annots->count];
|
||||
|
||||
annot->type = WESTON_DEBUG_ANNOTATION_INT_VAL;
|
||||
annot->ivalue = value;
|
||||
annot->key = key;
|
||||
|
||||
annots->count++;
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
perfetto_annotate_float(struct weston_debug_annotations *annots,
|
||||
const char *key,
|
||||
float value)
|
||||
{
|
||||
struct weston_debug_annotation *annot = &annots->annots[annots->count];
|
||||
|
||||
annot->type = WESTON_DEBUG_ANNOTATION_FLOAT_VAL;
|
||||
annot->fvalue = value;
|
||||
annot->key = key;
|
||||
|
||||
annots->count++;
|
||||
}
|
||||
|
||||
WL_EXPORT void
|
||||
perfetto_annotate_string(struct weston_debug_annotations *annots,
|
||||
const char *key,
|
||||
const char *value)
|
||||
{
|
||||
struct weston_debug_annotation *annot = &annots->annots[annots->count];
|
||||
|
||||
annot->type = WESTON_DEBUG_ANNOTATION_STR_VAL;
|
||||
annot->svalue = value;
|
||||
annot->key = key;
|
||||
|
||||
annots->count++;
|
||||
}
|
||||
45
libweston/perfetto/annotations.h
Normal file
45
libweston/perfetto/annotations.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (C) 2026 Amazon.com, Inc. or its affiliates
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial
|
||||
* portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <libweston/libweston.h>
|
||||
|
||||
#include "perfetto/u_perfetto.h"
|
||||
|
||||
void
|
||||
perfetto_annotate_int(struct weston_debug_annotations *annots,
|
||||
const char *key,
|
||||
int value);
|
||||
|
||||
void
|
||||
perfetto_annotate_float(struct weston_debug_annotations *annots,
|
||||
const char *key,
|
||||
float value);
|
||||
|
||||
void
|
||||
perfetto_annotate_string(struct weston_debug_annotations *annots,
|
||||
const char *key,
|
||||
const char *value);
|
||||
|
|
@ -228,48 +228,6 @@ util_perfetto_trace_commit_annotate_func_flow(uint64_t id, const char *name,
|
|||
});
|
||||
}
|
||||
|
||||
void
|
||||
perfetto_annotate_int(struct weston_debug_annotations *annots,
|
||||
const char *key,
|
||||
int value)
|
||||
{
|
||||
struct weston_debug_annotation *annot = &annots->annots[annots->count];
|
||||
|
||||
annot->type = WESTON_DEBUG_ANNOTATION_INT_VAL;
|
||||
annot->ivalue = value;
|
||||
annot->key = key;
|
||||
|
||||
annots->count++;
|
||||
}
|
||||
|
||||
void
|
||||
perfetto_annotate_float(struct weston_debug_annotations *annots,
|
||||
const char *key,
|
||||
float value)
|
||||
{
|
||||
struct weston_debug_annotation *annot = &annots->annots[annots->count];
|
||||
|
||||
annot->type = WESTON_DEBUG_ANNOTATION_FLOAT_VAL;
|
||||
annot->fvalue = value;
|
||||
annot->key = key;
|
||||
|
||||
annots->count++;
|
||||
}
|
||||
|
||||
void
|
||||
perfetto_annotate_string(struct weston_debug_annotations *annots,
|
||||
const char *key,
|
||||
const char *value)
|
||||
{
|
||||
struct weston_debug_annotation *annot = &annots->annots[annots->count];
|
||||
|
||||
annot->type = WESTON_DEBUG_ANNOTATION_STR_VAL;
|
||||
annot->svalue = value;
|
||||
annot->key = key;
|
||||
|
||||
annots->count++;
|
||||
}
|
||||
|
||||
class UtilPerfettoObserver : public perfetto::TrackEventSessionObserver {
|
||||
public:
|
||||
UtilPerfettoObserver() { perfetto::TrackEvent::AddSessionObserver(this); }
|
||||
|
|
|
|||
|
|
@ -97,21 +97,6 @@ uint64_t util_perfetto_next_id(void);
|
|||
|
||||
uint64_t util_perfetto_new_track(const char *name);
|
||||
|
||||
void
|
||||
perfetto_annotate_int(struct weston_debug_annotations *annots,
|
||||
const char *key,
|
||||
int value);
|
||||
|
||||
void
|
||||
perfetto_annotate_float(struct weston_debug_annotations *annots,
|
||||
const char *key,
|
||||
float value);
|
||||
|
||||
void
|
||||
perfetto_annotate_string(struct weston_debug_annotations *annots,
|
||||
const char *key,
|
||||
const char *value);
|
||||
|
||||
#else /* HAVE_PERFETTO */
|
||||
|
||||
static inline void
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#ifndef WESTON_TRACE_H
|
||||
#define WESTON_TRACE_H
|
||||
|
||||
#include "perfetto/annotations.h"
|
||||
#include "perfetto/u_perfetto.h"
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue