mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 02:38:04 +02:00
util/u_trace: Print tracepoints with indentation
Thjis patch adds u_tracepoint_type to mark begin/end tracepoints. Tracepoints inside a begin/end range will be printed with an indentation. Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41271>
This commit is contained in:
parent
bb9fc4a5fc
commit
654f1f377e
4 changed files with 32 additions and 8 deletions
|
|
@ -144,14 +144,23 @@ print_txt_event(struct u_trace_context *utctx,
|
|||
int32_t delta,
|
||||
const void *indirect)
|
||||
{
|
||||
if (evt->tp->print) {
|
||||
fprintf(utctx->out, "%016" PRIu64 " %+9d: %s: ", ns, delta,
|
||||
evt->tp->name);
|
||||
if (evt->tp->type == u_tracepoint_type_end_range)
|
||||
utctx->indentation--;
|
||||
|
||||
fprintf(utctx->out, "%016" PRIu64 " %+9d: ", ns, delta);
|
||||
|
||||
for (uint32_t i = 0; i < utctx->indentation; i++)
|
||||
fprintf(utctx->out, " ");
|
||||
|
||||
fprintf(utctx->out, "%s ", evt->tp->name);
|
||||
|
||||
if (evt->tp->print)
|
||||
evt->tp->print(utctx->out, evt->payload, indirect);
|
||||
} else {
|
||||
fprintf(utctx->out, "%016" PRIu64 " %+9d: %s\n", ns, delta,
|
||||
evt->tp->name);
|
||||
}
|
||||
else
|
||||
fprintf(utctx->out, "\n");
|
||||
|
||||
if (evt->tp->type == u_tracepoint_type_begin_range)
|
||||
utctx->indentation++;
|
||||
}
|
||||
|
||||
static struct u_trace_printer txt_printer = {
|
||||
|
|
|
|||
|
|
@ -253,6 +253,9 @@ struct u_trace_context {
|
|||
uint32_t event_nr;
|
||||
bool start_of_frame;
|
||||
|
||||
/* State for printing timestamps. */
|
||||
uint32_t indentation;
|
||||
|
||||
void *dummy_indirect_data;
|
||||
|
||||
/* list of unprocessed trace chunks in fifo order: */
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ class Tracepoint(object):
|
|||
"""
|
||||
def __init__(self, name, args=[], toggle_name=None,
|
||||
tp_struct=None, tp_print=None, tp_perfetto=None,
|
||||
tp_markers=None, tp_flags=[], need_cs_param=True):
|
||||
tp_markers=None, tp_flags=[], need_cs_param=True,
|
||||
tp_type="u_tracepoint_type_marker"):
|
||||
"""Parameters:
|
||||
|
||||
- name: the tracepoint name, a tracepoint function with the given
|
||||
|
|
@ -96,6 +97,7 @@ class Tracepoint(object):
|
|||
self.tp_flags = tp_flags
|
||||
self.toggle_name = toggle_name
|
||||
self.need_cs_param = need_cs_param
|
||||
self.tp_type = tp_type
|
||||
|
||||
TRACEPOINTS[name] = self
|
||||
if toggle_name is not None and toggle_name not in TRACEPOINTS_TOGGLES:
|
||||
|
|
@ -539,6 +541,7 @@ static const struct u_tracepoint __tp_${trace_name} = {
|
|||
,
|
||||
${0 if len(trace.tp_flags) == 0 else " | ".join(trace.tp_flags)},
|
||||
${index},
|
||||
${trace.tp_type},
|
||||
__print_${trace_name},
|
||||
__print_json_${trace_name},
|
||||
% if trace.tp_perfetto is not None:
|
||||
|
|
|
|||
|
|
@ -39,6 +39,12 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum u_tracepoint_type {
|
||||
u_tracepoint_type_begin_range,
|
||||
u_tracepoint_type_end_range,
|
||||
u_tracepoint_type_marker,
|
||||
};
|
||||
|
||||
/**
|
||||
* Tracepoint descriptor.
|
||||
*/
|
||||
|
|
@ -63,6 +69,9 @@ struct u_tracepoint {
|
|||
* to event->set_stage_iid().
|
||||
*/
|
||||
uint16_t tp_idx;
|
||||
|
||||
enum u_tracepoint_type type;
|
||||
|
||||
void (*print)(FILE *out, const void *payload, const void *indirect);
|
||||
void (*print_json)(FILE *out, const void *payload, const void *indirect);
|
||||
#ifdef HAVE_PERFETTO
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue