mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
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:
parent
44aefc8777
commit
b57ccf3517
@ -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; }
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user