From 25698cd1b811ff8dca54a236571e2a4adba2ed84 Mon Sep 17 00:00:00 2001 From: Aliaksey Kandratsenka Date: Tue, 27 Jun 2023 16:37:59 -0400 Subject: [PATCH] improve diagnostics for stacktrace_unittest --- Makefile.am | 2 ++ src/tests/stacktrace_unittest.cc | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 2790cb1..4867106 100644 --- a/Makefile.am +++ b/Makefile.am @@ -346,6 +346,8 @@ STACKTRACE_UNITTEST_INCLUDES = src/config_for_unittests.h \ stacktrace_unittest_SOURCES = src/tests/stacktrace_unittest.cc \ $(STACKTRACE_UNITTEST_INCLUDES) stacktrace_unittest_LDADD = libstacktrace.la liblogging.la libfake_stacktrace_scope.la $(STACKTRACE_UNITTEST_LIBS) +# nice to have. Allows glibc's backtrace_symbols to work. +stacktrace_unittest_LDFLAGS = -export-dynamic ### Documentation dist_doc_DATA += diff --git a/src/tests/stacktrace_unittest.cc b/src/tests/stacktrace_unittest.cc index bfb6352..d47ffb7 100644 --- a/src/tests/stacktrace_unittest.cc +++ b/src/tests/stacktrace_unittest.cc @@ -54,7 +54,12 @@ #include #include "tests/testutil.h" -namespace { +static bool verbosity_setup = ([] () { + // Lets try have more details printed for test by asking for verbose + // option. + setenv("TCMALLOC_STACKTRACE_METHOD_VERBOSE", "t", 0); + return true; +})(); // Obtain a backtrace, verify that the expected callers are present in the // backtrace, and maybe print the backtrace to stdout. @@ -124,6 +129,8 @@ void CheckRetAddrIsInFunction(void *ret_addr, const AddressRange &range) //-----------------------------------------------------------------------// +extern "C" { + #if TEST_UCONTEXT_BITS struct get_stack_trace_args { @@ -319,7 +326,8 @@ void ATTRIBUTE_NOINLINE CheckStackTrace(int i) { DECLARE_ADDRESS_LABEL(end); } -} // namespace +} // extern "C" + //-----------------------------------------------------------------------// int main(int argc, char ** argv) {