mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-01 23:20:55 +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:
|
public:
|
||||||
|
|
||||||
|
Entry() : _entry(0) { };
|
||||||
|
|
||||||
size_t length() const { return _entry->len; }
|
size_t length() const { return _entry->len; }
|
||||||
char const *data() const { return _entry->data; }
|
char const *data() const { return _entry->data; }
|
||||||
|
|
||||||
|
@ -76,8 +76,10 @@ class Trace_buffer
|
|||||||
/* iterate over all entries that were not processed yet */
|
/* iterate over all entries that were not processed yet */
|
||||||
for (; wrapped || !entry.last(); entry = _buffer.next(entry)) {
|
for (; wrapped || !entry.last(); entry = _buffer.next(entry)) {
|
||||||
/* if buffer wrapped, we pass the last entry once and continue at first entry */
|
/* if buffer wrapped, we pass the last entry once and continue at first entry */
|
||||||
|
bool applied_wrap = false;
|
||||||
if (wrapped && entry.last()) {
|
if (wrapped && entry.last()) {
|
||||||
wrapped = false;
|
wrapped = false;
|
||||||
|
applied_wrap = true;
|
||||||
entry = _buffer.first();
|
entry = _buffer.first();
|
||||||
if (entry.last()) {
|
if (entry.last()) {
|
||||||
new_curr = entry;
|
new_curr = entry;
|
||||||
@ -89,8 +91,11 @@ class Trace_buffer
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!functor(entry))
|
if (!functor(entry)) {
|
||||||
|
if (applied_wrap)
|
||||||
|
new_curr = Trace::Buffer::Entry();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
new_curr = entry;
|
new_curr = entry;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user