trace_buffer: fix wrap corner case

If the functor reading the first entry after wrap-around returned false,
the wrapping was not applied successfully.

genodelabs/genode#4430
This commit is contained in:
Johannes Schlatow 2022-02-17 12:06:12 +01:00 committed by Christian Helmuth
parent 44aefc8777
commit b57ccf3517
2 changed files with 8 additions and 1 deletions

View File

@ -124,6 +124,8 @@ class Genode::Trace::Buffer
public:
Entry() : _entry(0) { };
size_t length() const { return _entry->len; }
char const *data() const { return _entry->data; }

View File

@ -76,8 +76,10 @@ class Trace_buffer
/* iterate over all entries that were not processed yet */
for (; wrapped || !entry.last(); entry = _buffer.next(entry)) {
/* if buffer wrapped, we pass the last entry once and continue at first entry */
bool applied_wrap = false;
if (wrapped && entry.last()) {
wrapped = false;
applied_wrap = true;
entry = _buffer.first();
if (entry.last()) {
new_curr = entry;
@ -89,8 +91,11 @@ class Trace_buffer
continue;
}
if (!functor(entry))
if (!functor(entry)) {
if (applied_wrap)
new_curr = Trace::Buffer::Entry();
break;
}
new_curr = entry;
}