summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKirill Müller <krlmlr@mailbox.org>2020-02-25 09:09:22 +0100
committerAliaksey Kandratsenka <alkondratenko@gmail.com>2020-03-08 23:58:13 -0700
commit4cddede3990a96969aac9ff13ce3c8195ec91ce7 (patch)
treea5f227ed19ea3771377f36973157880127f27d23 /src
parentdb7aa547abb5abdd558587a15502584cbc825438 (diff)
downloadgperftools-4cddede3990a96969aac9ff13ce3c8195ec91ce7.tar.gz
New ProfilerGetStackTrace()
Diffstat (limited to 'src')
-rw-r--r--src/gperftools/profiler.h4
-rw-r--r--src/profiler.cc9
2 files changed, 13 insertions, 0 deletions
diff --git a/src/gperftools/profiler.h b/src/gperftools/profiler.h
index 1e7eb12..d444b4a 100644
--- a/src/gperftools/profiler.h
+++ b/src/gperftools/profiler.h
@@ -162,6 +162,10 @@ struct ProfilerState {
};
PERFTOOLS_DLL_DECL void ProfilerGetCurrentState(struct ProfilerState* state);
+/* Returns the current stack trace, to be called from a SIGPROF handler. */
+PERFTOOLS_DLL_DECL int ProfilerGetStackTrace(
+ void** result, int max_depth, int skip_count, const void *uc);
+
#ifdef __cplusplus
} // extern "C"
#endif
diff --git a/src/profiler.cc b/src/profiler.cc
index 3bd0ed9..077b6b8 100644
--- a/src/profiler.cc
+++ b/src/profiler.cc
@@ -402,6 +402,11 @@ extern "C" PERFTOOLS_DLL_DECL void ProfilerGetCurrentState(
CpuProfiler::instance_.GetCurrentState(state);
}
+extern "C" PERFTOOLS_DLL_DECL int ProfilerGetStackTrace(
+ void** result, int max_depth, int skip_count, const void *uc) {
+ return GetStackTraceWithContext(result, max_depth, skip_count, uc);
+}
+
#else // OS_CYGWIN
// ITIMER_PROF doesn't work under cygwin. ITIMER_REAL is available, but doesn't
@@ -420,6 +425,10 @@ extern "C" void ProfilerStop() { }
extern "C" void ProfilerGetCurrentState(ProfilerState* state) {
memset(state, 0, sizeof(*state));
}
+extern "C" int ProfilerGetStackTrace(
+ void** result, int max_depth, int skip_count, const void *uc) {
+ return 0;
+}
#endif // OS_CYGWIN