From 12fc9a0fbbcd9b741ce494bcf802769da68979af Mon Sep 17 00:00:00 2001 From: Christian Helmuth Date: Wed, 12 Jul 2023 08:04:53 +0200 Subject: [PATCH] trace_logger: log priority of trace subject Optionally log thread priority with ... The commit also applies a cleanup of format calculations. --- .../os/recipes/pkg/test-trace_logger/runtime | 2 +- repos/os/src/app/trace_logger/README | 5 ++ repos/os/src/app/trace_logger/main.cc | 20 +++++--- repos/os/src/app/trace_logger/monitor.cc | 50 +++++++++++++------ repos/os/src/app/trace_logger/monitor.h | 4 +- 5 files changed, 54 insertions(+), 27 deletions(-) diff --git a/repos/os/recipes/pkg/test-trace_logger/runtime b/repos/os/recipes/pkg/test-trace_logger/runtime index d01899729f..51dbf17007 100644 --- a/repos/os/recipes/pkg/test-trace_logger/runtime +++ b/repos/os/recipes/pkg/test-trace_logger/runtime @@ -47,7 +47,7 @@ - + diff --git a/repos/os/src/app/trace_logger/README b/repos/os/src/app/trace_logger/README index 3074091fa1..1b1be7475b 100644 --- a/repos/os/src/app/trace_logger/README +++ b/repos/os/src/app/trace_logger/README @@ -14,6 +14,8 @@ the default value for each attribute except the policy.thread and policy.label: ! +struct Formatted +{ + char const *type = ""; + + T const &value; + + Formatted(T const &value) : value(value) { } + Formatted(char const *type, T const &value) : type(type), value(value) { } + + void print(Genode::Output &out) const + { + Genode::print(out, " ", type, value); } }; @@ -130,13 +147,14 @@ void Monitor::apply_formatting(Formatting &formatting) const typedef Trace::Subject_info Subject_info; - expand(formatting.thread_name, Quoted_name{_info.thread_name()}); + expand(formatting.thread_name, Formatted("Thread ", Quoted_name{_info.thread_name()})); expand(formatting.affinity, Formatted_affinity{_info.affinity()}); - expand(formatting.state, Subject_info::state_name(_info.state())); - expand(formatting.total_tc, _info.execution_time().thread_context); - expand(formatting.recent_tc, _recent_exec_time.thread_context); - expand(formatting.total_sc, _info.execution_time().scheduling_context); - expand(formatting.recent_sc, _recent_exec_time.scheduling_context); + expand(formatting.state, Formatted(Subject_info::state_name(_info.state()))); + expand(formatting.prio, Formatted("prio:", _info.execution_time().priority)); + expand(formatting.total_tc, Formatted("total:", _info.execution_time().thread_context)); + expand(formatting.recent_tc, Formatted("recent:", _recent_exec_time.thread_context)); + expand(formatting.total_sc, Formatted("total_sc:", _info.execution_time().scheduling_context)); + expand(formatting.recent_sc, Formatted("recent_sc:", _recent_exec_time.scheduling_context)); } @@ -150,15 +168,15 @@ void Monitor::print(Formatting fmt, Level_of_detail detail) typedef Trace::Subject_info Subject_info; Subject_info::State const state = _info.state(); - log(" Thread ", Left_aligned(fmt.thread_name, Quoted_name{_info.thread_name()}), - " ", Left_aligned(fmt.affinity, Formatted_affinity{_info.affinity()}), - " ", Conditional(detail.state, - Left_aligned(fmt.state + 1, Subject_info::state_name(state))), - "total:", Left_aligned(fmt.total_tc, _info.execution_time().thread_context), " " - "recent:", Left_aligned(fmt.recent_tc, _recent_exec_time.thread_context), - Conditional(detail.sc_time, String<80>( - " total_sc:", Left_aligned(fmt.total_sc, _info.execution_time().scheduling_context), - " recent_sc:", _recent_exec_time.scheduling_context))); + log(Left_aligned(fmt.thread_name, Formatted("Thread ", Quoted_name{_info.thread_name()})), + Left_aligned(fmt.affinity, Formatted_affinity{_info.affinity()}), + " ", + Conditional(detail.state, Left_aligned(fmt.state, Formatted("", Subject_info::state_name(state)))), + Conditional(detail.prio, Left_aligned(fmt.prio, Formatted("prio:", _info.execution_time().priority))), + Left_aligned(fmt.total_tc, Formatted("total:", _info.execution_time().thread_context)), + Left_aligned(fmt.recent_tc, Formatted("recent:", _recent_exec_time.thread_context)), + Conditional(detail.sc_time, Left_aligned(fmt.total_sc, Formatted("total_sc:", _info.execution_time().scheduling_context))), + Conditional(detail.sc_time, Left_aligned(fmt.recent_sc, Formatted("recent_sc:", _recent_exec_time.scheduling_context)))); /* print all buffer entries that we haven't yet printed */ _buffer.for_each_new_entry([&] (Trace::Buffer::Entry entry) { diff --git a/repos/os/src/app/trace_logger/monitor.h b/repos/os/src/app/trace_logger/monitor.h index 411d1092b0..44110fca15 100644 --- a/repos/os/src/app/trace_logger/monitor.h +++ b/repos/os/src/app/trace_logger/monitor.h @@ -64,7 +64,7 @@ class Monitor : public Monitor_base, struct Formatting { - unsigned thread_name, affinity, state, total_tc, recent_tc, total_sc, recent_sc; + unsigned thread_name, affinity, prio, state, total_tc, recent_tc, total_sc, recent_sc; }; Monitor(Genode::Trace::Connection &trace, @@ -76,7 +76,7 @@ class Monitor : public Monitor_base, */ void apply_formatting(Formatting &) const; - struct Level_of_detail { bool state, active_only, sc_time; }; + struct Level_of_detail { bool state, active_only, prio, sc_time; }; void print(Formatting, Level_of_detail);