From 9911361e8176fd2290b36f332ec194dcd1135d42 Mon Sep 17 00:00:00 2001
From: Jon Turney <jon.turney@dronecode.org.uk>
Date: Sat, 22 Feb 2014 15:59:22 +0000
Subject: [PATCH 15/29] Use a default debug-id of all zeros when no CV record
 is present

This lets us do something slightly useful with current binaries
which are produced without a CV record, but there is no guarantee
that the actually match.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
---
 src/common/pecoff/pecoff_file_id.cc | 8 ++++++++
 src/processor/minidump.cc           | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/src/common/pecoff/pecoff_file_id.cc b/src/common/pecoff/pecoff_file_id.cc
index 47c2763f..04563c86 100644
--- a/src/common/pecoff/pecoff_file_id.cc
+++ b/src/common/pecoff/pecoff_file_id.cc
@@ -32,6 +32,7 @@
 
 #include "common/pecoff/pecoff_file_id.h"
 
+#include <string.h>
 #include "common/pecoff/pecoffutils.h"
 
 namespace google_breakpad {
@@ -73,11 +74,18 @@ bool PeCoffFileID::PeCoffFileIdentifierFromMappedFile(const void* base,
                         age))
     return true;
 
+#if 1
+  // XXX: Fallback to a default debug_identifier.
+  memset(identifier, 0, kMDGUIDSize);
+  *age = 0;
+  return true;
+#else
   // Fall back on hashing the first page of the text section.
   // (This is of questionable value as the Windows Minidump writer doesn't have
   // this feature)
   return HashPeCoffTextSection(reinterpret_cast<const uint8_t *>(base),
                                identifier);
+#endif
 }
 
 }  // namespace google_breakpad
diff --git a/src/processor/minidump.cc b/src/processor/minidump.cc
index 4678a5ef..cbf18404 100644
--- a/src/processor/minidump.cc
+++ b/src/processor/minidump.cc
@@ -2181,6 +2181,14 @@ string MinidumpModule::debug_identifier() const {
 
   // TODO(mmentovai): on the Mac, provide fallbacks as in code_identifier().
 
+  // XXX: PE generated with gcc don't currently have CV records, so the Windows
+  // minidumper can't record any identifier information, so there's no useful
+  // identifier for us to match with.  Fallback to a default debug_identifier.
+  if (identifier.empty())
+  {
+    identifier = "000000000000000000000000000000000";
+  }
+
   // Relatively common case
   BPLOG_IF(INFO, identifier.empty()) << "MinidumpModule could not determine "
                                         "debug_identifier for " << *name_;
-- 
2.15.0

