improve diagnostics for stacktrace_unittest

This commit is contained in:
Aliaksey Kandratsenka 2023-06-27 16:37:59 -04:00
parent a25e7fa8b0
commit 25698cd1b8
2 changed files with 12 additions and 2 deletions

View File

@ -346,6 +346,8 @@ STACKTRACE_UNITTEST_INCLUDES = src/config_for_unittests.h \
stacktrace_unittest_SOURCES = src/tests/stacktrace_unittest.cc \ stacktrace_unittest_SOURCES = src/tests/stacktrace_unittest.cc \
$(STACKTRACE_UNITTEST_INCLUDES) $(STACKTRACE_UNITTEST_INCLUDES)
stacktrace_unittest_LDADD = libstacktrace.la liblogging.la libfake_stacktrace_scope.la $(STACKTRACE_UNITTEST_LIBS) 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 ### Documentation
dist_doc_DATA += dist_doc_DATA +=

View File

@ -54,7 +54,12 @@
#include <gperftools/stacktrace.h> #include <gperftools/stacktrace.h>
#include "tests/testutil.h" #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 // Obtain a backtrace, verify that the expected callers are present in the
// backtrace, and maybe print the backtrace to stdout. // 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 #if TEST_UCONTEXT_BITS
struct get_stack_trace_args { struct get_stack_trace_args {
@ -319,7 +326,8 @@ void ATTRIBUTE_NOINLINE CheckStackTrace(int i) {
DECLARE_ADDRESS_LABEL(end); DECLARE_ADDRESS_LABEL(end);
} }
} // namespace } // extern "C"
//-----------------------------------------------------------------------// //-----------------------------------------------------------------------//
int main(int argc, char ** argv) { int main(int argc, char ** argv) {