trace_logger: omit inactive subjects by default

This patch reduces repetitive log output by omitting inactive trace
subjects from the log output. The information about all subjects can
still be dumped by setting 'verbose="yes"'.

Issue #4448
This commit is contained in:
Norman Feske 2022-03-11 15:13:39 +01:00 committed by Christian Helmuth
parent ceb91732bf
commit f7270c44cb
5 changed files with 22 additions and 10 deletions

View File

@ -26,7 +26,7 @@ class Trace_buffer
private:
Genode::Trace::Buffer &_buffer;
Genode::Trace::Buffer::Entry _curr { _buffer.first() };
Genode::Trace::Buffer::Entry _curr { _buffer.first() };
unsigned long long _lost_count { 0 };
public:
@ -48,7 +48,7 @@ class Trace_buffer
_lost_count = (unsigned)_buffer.lost_entries();
}
Trace::Buffer::Entry entry { _curr };
Trace::Buffer::Entry entry { _curr };
/**
* Iterate over all entries that were not processed yet.
@ -59,6 +59,7 @@ class Trace_buffer
* if the 'last' end of the buffer (highest address) was reached.
*/
for (; !entry.head(); entry = _buffer.next(entry)) {
/* continue at first entry if we hit the end of the buffer */
if (entry.last())
entry = _buffer.first();
@ -76,8 +77,9 @@ class Trace_buffer
if (update) _curr = entry;
}
void * address() const { return &_buffer; }
void * address() const { return &_buffer; }
bool empty() const { return _curr.head(); }
};
#endif /* _TRACE__TRACE_BUFFER_H_ */

View File

@ -36,6 +36,7 @@ This is a short description of the tags and attributes:
:config.verbose:
Optional. Toggles wether the trace_logger shall log debugging information.
If enabled, even inactive trace subjects appear in the log.
:config.session_ram:
Optional. Amount of RAM donated to the trace session.

View File

@ -150,7 +150,9 @@ class Main
log("");
log("--- Report ", _report_id++, " (", _num_monitors, "/", _num_subjects, " subjects) ---");
new_monitors.for_each([&] (Monitor &monitor) {
monitor.print(_activity, _affinity);
monitor.print(Monitor::Level_of_detail { .activity = _activity,
.affinity = _affinity,
.active_only = !_verbose });
});
}

View File

@ -86,8 +86,13 @@ void Monitor::update_info(Trace::Subject_info const &info)
}
void Monitor::print(bool activity, bool affinity)
void Monitor::print(Level_of_detail detail)
{
/* skip output for a subject with no recent activity */
bool const inactive = (_recent_exec_time == 0) && _buffer.empty();
if (detail.active_only && inactive)
return;
/* print general subject information */
typedef Trace::Subject_info Subject_info;
Subject_info::State const state = _info.state();
@ -98,13 +103,13 @@ void Monitor::print(bool activity, bool affinity)
"\">");
/* print subjects activity if desired */
if (activity)
if (detail.activity)
log(" <activity total=\"", _info.execution_time().thread_context,
"\" recent=\"", _recent_exec_time,
"\">");
/* print subjects affinity if desired */
if (affinity)
if (detail.affinity)
log(" <affinity xpos=\"", _info.affinity().xpos(),
"\" ypos=\"", _info.affinity().ypos(),
"\">");
@ -139,7 +144,7 @@ void Monitor::print(bool activity, bool affinity)
if (printed_buf_entries)
log(" </buffer>");
else
log(" <buffer />");
log(" <buffer/>");
log("</subject>");
}

View File

@ -67,7 +67,9 @@ class Monitor : public Monitor_base,
Genode::Trace::Subject_id subject_id,
Genode::Trace::Subject_info const &info);
void print(bool activity, bool affinity);
struct Level_of_detail { bool activity, affinity, active_only; };
void print(Level_of_detail);
/**************