Add the messages skipped when time skips an event
The first question ends up being "what messages triggered this?", so
let's just print them out
Change-Id: I1deb37037376544be0ac34c6e7588715a3674e16
diff --git a/aos/events/logging/logger.cc b/aos/events/logging/logger.cc
index 962a107..91cf7dc 100644
--- a/aos/events/logging/logger.cc
+++ b/aos/events/logging/logger.cc
@@ -1486,7 +1486,8 @@
const std::chrono::nanoseconds kTolerance{3};
if (!FLAGS_skip_order_validation) {
CHECK_GE(next_time, state->monotonic_now())
- << ": Time skipped the next event.";
+ << ": Time skipped the next event, just sent "
+ << timestamped_message << ", sending next " << state->PeekOldest();
for (size_t i = 0; i < states_.size(); ++i) {
CHECK_GE(states_[i]->monotonic_now(), before_times[i] - kTolerance)
@@ -1501,7 +1502,9 @@
LOG(WARNING) << "Check failed: next_time >= "
"state->monotonic_now() ("
<< next_time << " vs. " << state->monotonic_now()
- << "): Time skipped the next event.";
+ << "): Time skipped the next event, just sent "
+ << timestamped_message << ", sending next "
+ << state->PeekOldest();
}
for (size_t i = 0; i < states_.size(); ++i) {
if (states_[i]->monotonic_now() < before_times[i] - kTolerance) {
@@ -1998,6 +2001,10 @@
return &(sender->second);
}
+const TimestampedMessage &LogReader::State::PeekOldest() {
+ return std::get<0>(sorted_messages_.front());
+}
+
TimestampedMessage LogReader::State::PopOldest(bool *update_time) {
CHECK_GT(sorted_messages_.size(), 0u);
diff --git a/aos/events/logging/logger.h b/aos/events/logging/logger.h
index a117b5a..e71f31d 100644
--- a/aos/events/logging/logger.h
+++ b/aos/events/logging/logger.h
@@ -504,6 +504,9 @@
// filter to change the time offset estimation function.
TimestampedMessage PopOldest(bool *update_time);
+ // Returns the oldest message (if it exists) non destructively.
+ const TimestampedMessage &PeekOldest();
+
// Returns the monotonic time of the oldest message.
monotonic_clock::time_point OldestMessageTime() const;