aboutsummaryrefslogtreecommitdiff
path: root/src/stacktrace_libunwind-inl.h
diff options
context:
space:
mode:
authorSatish Patel <satish.patel@linaro.org>2016-04-26 10:34:31 +0530
committerSatish Patel <satish.patel@linaro.org>2016-04-26 10:34:31 +0530
commit4c18ea2aa859992445ffc48c70f19e792c904f25 (patch)
treedf93855f65d3a7f4227c7d35029890e4fe2f8dde /src/stacktrace_libunwind-inl.h
parent4e447c8194c7165502f245c7c2a2227c568f6fa5 (diff)
downloadgperftools-4c18ea2aa859992445ffc48c70f19e792c904f25.tar.gz
tcmalloc: chromium port
Ported chromium port of gperftool. The port has all necessary changes for android platform. Details can be tracked at https://chromium.googlesource.com/chromium/src/third_party/tcmalloc/chromium/ e.g. - atomic operations for linux - property based configurations porting using system property for Android case (reading environment variables at startup) - change in config.h as per Android platform - c++11 fixes - Fixed gcc errors/warnings - logging changes as per android log libarary - time calculation and abort call to tcmalloc (For linux)
Diffstat (limited to 'src/stacktrace_libunwind-inl.h')
-rw-r--r--src/stacktrace_libunwind-inl.h30
1 files changed, 3 insertions, 27 deletions
diff --git a/src/stacktrace_libunwind-inl.h b/src/stacktrace_libunwind-inl.h
index 6f361ec..82b0cfe 100644
--- a/src/stacktrace_libunwind-inl.h
+++ b/src/stacktrace_libunwind-inl.h
@@ -1,4 +1,3 @@
-// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*-
// Copyright (c) 2005, Google Inc.
// All rights reserved.
//
@@ -47,8 +46,6 @@ extern "C" {
#include <libunwind.h>
}
#include "gperftools/stacktrace.h"
-
-#include "base/basictypes.h"
#include "base/logging.h"
// Sometimes, we can try to get a stack trace from within a stack
@@ -58,11 +55,7 @@ extern "C" {
// recursive request, we'd end up with infinite recursion or deadlock.
// Luckily, it's safe to ignore those subsequent traces. In such
// cases, we return 0 to indicate the situation.
-static __thread int recursive ATTR_INITIAL_EXEC;
-
-#if defined(TCMALLOC_ENABLE_UNWIND_FROM_UCONTEXT) && (defined(__i386__) || defined(__x86_64__)) && defined(__GNU_LIBRARY__)
-#define BASE_STACKTRACE_UNW_CONTEXT_IS_UCONTEXT 1
-#endif
+static __thread int recursive;
#endif // BASE_STACKTRACE_LIBINWIND_INL_H_
@@ -80,7 +73,7 @@ static __thread int recursive ATTR_INITIAL_EXEC;
// int max_depth: the size of the result (and sizes) array(s)
// int skip_count: how many stack pointers to skip before storing in result
// void* ucp: a ucontext_t* (GetStack{Trace,Frames}WithContext only)
-static int GET_STACK_TRACE_OR_FRAMES {
+int GET_STACK_TRACE_OR_FRAMES {
void *ip;
int n = 0;
unw_cursor_t cursor;
@@ -94,27 +87,10 @@ static int GET_STACK_TRACE_OR_FRAMES {
}
++recursive;
-#if (IS_WITH_CONTEXT && defined(BASE_STACKTRACE_UNW_CONTEXT_IS_UCONTEXT))
- if (ucp) {
- uc = *(static_cast<unw_context_t *>(const_cast<void *>(ucp)));
- /* this is a bit weird. profiler.cc calls us with signal's ucontext
- * yet passing us 2 as skip_count and essentially assuming we won't
- * use ucontext. */
- /* In order to fix that I'm going to assume that if ucp is
- * non-null we're asked to ignore skip_count in case we're
- * able to use ucp */
- skip_count = 0;
- } else {
- unw_getcontext(&uc);
- skip_count += 2; // Do not include current and parent frame
- }
-#else
unw_getcontext(&uc);
- skip_count += 2; // Do not include current and parent frame
-#endif
-
int ret = unw_init_local(&cursor, &uc);
assert(ret >= 0);
+ skip_count++; // Do not include current frame
while (skip_count--) {
if (unw_step(&cursor) <= 0) {