Log invalid stack bound errors in trace.

Bug: 181012016
Change-Id: I9209044c462a383bd62c4bc9747d557025578c6c
diff --git a/src/trace_processor/importers/proto/proto_trace_parser.cc b/src/trace_processor/importers/proto/proto_trace_parser.cc
index 96c3833..93b248c 100644
--- a/src/trace_processor/importers/proto/proto_trace_parser.cc
+++ b/src/trace_processor/importers/proto/proto_trace_parser.cc
@@ -311,9 +311,17 @@
     if (entry.buffer_corrupted())
       context_->storage->IncrementIndexedStats(
           stats::heapprofd_buffer_corrupted, pid);
-    if (entry.buffer_overran())
+    if (entry.buffer_overran() ||
+        entry.client_error() ==
+            protos::pbzero::ProfilePacket::ProcessHeapSamples::
+                CLIENT_ERROR_HIT_TIMEOUT) {
       context_->storage->IncrementIndexedStats(stats::heapprofd_buffer_overran,
                                                pid);
+    }
+    if (entry.client_error()) {
+      context_->storage->SetIndexedStats(stats::heapprofd_client_error, pid,
+                                         entry.client_error());
+    }
     if (entry.rejected_concurrent())
       context_->storage->IncrementIndexedStats(
           stats::heapprofd_rejected_concurrent, pid);
diff --git a/src/trace_processor/storage/stats.h b/src/trace_processor/storage/stats.h
index 0e7f3eb..74ad737 100644
--- a/src/trace_processor/storage/stats.h
+++ b/src/trace_processor/storage/stats.h
@@ -136,6 +136,9 @@
   F(heapprofd_buffer_overran,           kIndexed, kDataLoss, kTrace,           \
       "The shared memory buffer between the target and heapprofd overran. "    \
       "The profile was truncated early. Indexed by target upid."),             \
+  F(heapprofd_client_error,             kIndexed, kError,    kTrace,           \
+      "The heapprofd client ran into a problem and disconnected. "             \
+      "See profile_packet.proto  for error codes."),                           \
   F(heapprofd_client_disconnected,      kIndexed, kInfo,     kTrace,    ""),   \
   F(heapprofd_malformed_packet,         kIndexed, kError,    kTrace,    ""),   \
   F(heapprofd_missing_packet,           kSingle,  kError,    kTrace,    ""),   \