Append function name/offset to kernel warning signature.

The current crash reporter signature for a kernel warning
is the 8-digit hex hash for the warning.  For convenience,
add the function name + offset to the hash, when it is
available.

BUG=chromium:328948
TEST=ran unit test

Change-Id: I8f047497c0556227a1dbdf650dabcd4c51aa8340
Reviewed-on: https://chromium-review.googlesource.com/180320
Tested-by: Luigi Semenzato <semenzato@chromium.org>
Reviewed-by: Sameer Nanda <snanda@chromium.org>
Commit-Queue: Luigi Semenzato <semenzato@chromium.org>
diff --git a/crash_reporter/warn_collector.l b/crash_reporter/warn_collector.l
index 0ca944a..6411b4d 100644
--- a/crash_reporter/warn_collector.l
+++ b/crash_reporter/warn_collector.l
@@ -124,6 +124,7 @@
 
 int WarnStart(void) {
   uint32_t hash;
+  char *spacep;
 
   if (filter)
     return 1;
@@ -139,7 +140,10 @@
   yyout = fopen(warn_dump_path, "w");
   if (yyout == NULL)
     Die("fopen %s failed: %s\n", warn_dump_path, strerror(errno));
-  fprintf(yyout, "%08x\n", hash);
+  spacep = index(yytext, ' ');
+  if (spacep == NULL || spacep[1] == '\0')
+    spacep = "unknown-function";
+  fprintf(yyout, "%08x-%s\n", hash, spacep + 1);
   return 1;
 }
 
diff --git a/crash_reporter/warn_collector_test.sh b/crash_reporter/warn_collector_test.sh
index 0790181..d9bb6f9 100755
--- a/crash_reporter/warn_collector_test.sh
+++ b/crash_reporter/warn_collector_test.sh
@@ -38,7 +38,7 @@
     fail "expected ${n_expected} lines in ${TESTLOG}, found this instead:
 $(<"${TESTLOG}")"
   fi
-  if egrep -qv '^[0-9a-f]{8}$' "${TESTLOG}"; then
+  if egrep -qv '^[0-9a-f]{8}' "${TESTLOG}"; then
     fail "found bad lines in ${TESTLOG}:
 $(<"${TESTLOG}")"
   fi