diff options
author | Derek Mauro <dmauro@google.com> | 2018-07-10 18:30:42 (GMT) |
---|---|---|
committer | Derek Mauro <dmauro@google.com> | 2018-07-10 18:30:42 (GMT) |
commit | 4c417877648f5f240aecead1c19d7c1fd340423b (patch) | |
tree | 845c821bd6bc6015f82cb10f911158a2c6a92a16 /googletest/src/gtest-internal-inl.h | |
parent | ba96d0b1161f540656efdaed035b3c062b60e006 (diff) | |
download | googletest-4c417877648f5f240aecead1c19d7c1fd340423b.zip googletest-4c417877648f5f240aecead1c19d7c1fd340423b.tar.gz googletest-4c417877648f5f240aecead1c19d7c1fd340423b.tar.bz2 |
Adds stacktrace support from Abseil to Google Test
This change adds the ability to generate stacktraces in Google Test on
both failures of assertions/expectations and on crashes. The
stacktrace support is conditionally available only when using Abseil
with Google Test.
To use this support, run the test under Bazel with a command like this:
bazel test --define absl=1 --test_env=GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1 //path/to/your:test
The "--define absl=1" part enables stacktraces on assertion/expectation
failures.
The "--test_env=GTEST_INSTALL_FAILURE_SIGNAL_HANDLER=1" part enables
the signal handler that logs a stacktrace in the event of a crash
(this also requires the "--define absl=1" part). This is not the
default since it may interfere with existing tests.
Diffstat (limited to 'googletest/src/gtest-internal-inl.h')
-rw-r--r-- | googletest/src/gtest-internal-inl.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/googletest/src/gtest-internal-inl.h b/googletest/src/gtest-internal-inl.h index e77c8b6..c5a4265 100644 --- a/googletest/src/gtest-internal-inl.h +++ b/googletest/src/gtest-internal-inl.h @@ -446,6 +446,16 @@ class OsStackTraceGetter : public OsStackTraceGetterInterface { virtual void UponLeavingGTest(); private: +#if GTEST_HAS_ABSL + Mutex mutex_; // Protects all internal state. + + // We save the stack frame below the frame that calls user code. + // We do this because the address of the frame immediately below + // the user code changes between the call to UponLeavingGTest() + // and any calls to the stack trace code from within the user code. + void* caller_frame_ = nullptr; +#endif // GTEST_HAS_ABSL + GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter); }; |