trace_buffer: revise trace buffer implementation

This commit simplifies the current implementation by overloading the
length field with a padding indicator in addition to the zero-length
head entry. This simplifies the iteration semantics as it eliminates
the need for determining whether a zero-length entries is the actual
head of the buffer or a padding at the buffer end.

genodelabs/genode#4434
This commit is contained in:
Johannes Schlatow
2022-02-04 16:56:21 +01:00
committed by Norman Feske
parent d24552f5e2
commit edc46d15f8
3 changed files with 149 additions and 93 deletions

View File

@ -105,17 +105,17 @@ class Trace_buffer_monitor
log("overflows: ", _buffer->wrapped());
log("read all remaining events");
for (; !_curr_entry.last(); _curr_entry = _buffer->next(_curr_entry)) {
for (; !_curr_entry.head(); _curr_entry = _buffer->next(_curr_entry)) {
if (_curr_entry.last())
_curr_entry = _buffer->first();
/* omit empty entries */
if (_curr_entry.length() == 0)
if (_curr_entry.empty())
continue;
char const * const data = _terminate_entry(_curr_entry);
if (data) { log(data); }
}
/* reset after we read all available entries */
_curr_entry = _buffer->first();
}
};