DCHECK for proper usage in StackTraceGetter.

Code that uses GoogleTest assertions without using GoogleTest itself
will result in calls to CurrentStackTrace without a preceding call to
UponLeavingGTest. Make this easier to diagnose with a DCHECK.

BUG=1039559

Change-Id: Id80aa918f2197625ec4b1025a99d778aed46c1d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2090413
Auto-Submit: Greg Thompson <grt@chromium.org>
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#747635}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 0870173a25630e17f018aa8a5486bd1a07f6e40d
diff --git a/custom/gtest/internal/custom/stack_trace_getter.cc b/custom/gtest/internal/custom/stack_trace_getter.cc
index 0e97bd1..e5fd95b 100644
--- a/custom/gtest/internal/custom/stack_trace_getter.cc
+++ b/custom/gtest/internal/custom/stack_trace_getter.cc
@@ -7,7 +7,12 @@
 #include <algorithm>
 #include <iterator>
 
+#include "base/logging.h"
+
 std::string StackTraceGetter::CurrentStackTrace(int max_depth, int skip_count) {
+  DCHECK(stack_trace_upon_leaving_gtest_)
+      << "Missing call to UponLeavingGTest. Are you using GoogleTest's "
+         "RUN_ALL_TESTS()?";
   base::debug::StackTrace stack_trace;
 
   size_t departure_frame_count = 0;