Make AOS starter print out application version on crashes

This way a journal log parser can unambiguously know what application
crahsed. Note that when an application crashes before it can send a
timing report out (e.g., if it crashes during initialization), this will
not end up helping.

Change-Id: I5217aecc395d2419ed7b622358f213cfd8ecd30f
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/starter/subprocess.h b/aos/starter/subprocess.h
index ff62117..1efd56d 100644
--- a/aos/starter/subprocess.h
+++ b/aos/starter/subprocess.h
@@ -124,6 +124,12 @@
     memory_cgroup_->SetLimit("memory.limit_in_bytes", limit);
   }
 
+  // Observe a timing report message, and save it if it is relevant to us.
+  // It is the responsibility of the caller to manage this, because the lifetime
+  // of the Application itself is such that it cannot own Fetchers readily.
+  void ObserveTimingReport(const aos::monotonic_clock::time_point send_time,
+                           const aos::timing::Report *msg);
+
  private:
   typedef aos::util::ScopedPipe::PipePair PipePair;
 
@@ -192,6 +198,12 @@
   aos::TimerHandler *start_timer_, *restart_timer_, *stop_timer_, *pipe_timer_,
       *child_status_handler_;
 
+  // Version string from the most recent valid timing report for this
+  // application. Cleared when the application restarts.
+  std::optional<std::string> latest_timing_report_version_;
+  aos::monotonic_clock::time_point last_timing_report_ =
+      aos::monotonic_clock::min_time;
+
   std::vector<std::function<void()>> on_change_;
 
   std::unique_ptr<MemoryCGroup> memory_cgroup_;