Skip to content

Commit 6cdb3d1

Browse files
Abseil Teamcopybara-github
authored andcommitted
Add internal API to allow bypassing stack trace fixups when needed
PiperOrigin-RevId: 822668786 Change-Id: I72d6178bbbde8b05b529e2d8297772cbb63758d0
1 parent 04e19d0 commit 6cdb3d1

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

absl/debugging/stacktrace.cc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ template <bool IS_STACK_FRAMES, bool IS_WITH_CONTEXT>
7878
ABSL_ATTRIBUTE_ALWAYS_INLINE inline int Unwind(void** result, uintptr_t* frames,
7979
int* sizes, size_t max_depth,
8080
int skip_count, const void* uc,
81-
int* min_dropped_frames) {
81+
int* min_dropped_frames,
82+
bool unwind_with_fixup = true) {
8283
static constexpr size_t kMinPageSize = 4096;
8384

8485
// Allow up to ~half a page, leaving some slack space for local variables etc.
@@ -100,7 +101,8 @@ ABSL_ATTRIBUTE_ALWAYS_INLINE inline int Unwind(void** result, uintptr_t* frames,
100101
bool must_free_frames = false;
101102
bool must_free_sizes = false;
102103

103-
bool unwind_with_fixup = internal_stacktrace::ShouldFixUpStack();
104+
unwind_with_fixup =
105+
unwind_with_fixup && internal_stacktrace::ShouldFixUpStack();
104106

105107
#ifdef _WIN32
106108
if (unwind_with_fixup) {
@@ -194,6 +196,14 @@ internal_stacktrace::GetStackFramesWithContext(void** result, uintptr_t* frames,
194196
min_dropped_frames);
195197
}
196198

199+
ABSL_ATTRIBUTE_NOINLINE ABSL_ATTRIBUTE_NO_TAIL_CALL int
200+
internal_stacktrace::GetStackTraceNoFixup(void** result, int max_depth,
201+
int skip_count) {
202+
return Unwind<false, false>(result, nullptr, nullptr,
203+
static_cast<size_t>(max_depth), skip_count,
204+
nullptr, nullptr, /*unwind_with_fixup=*/false);
205+
}
206+
197207
ABSL_ATTRIBUTE_NOINLINE ABSL_ATTRIBUTE_NO_TAIL_CALL int GetStackTrace(
198208
void** result, int max_depth, int skip_count) {
199209
return Unwind<false, false>(result, nullptr, nullptr,

absl/debugging/stacktrace.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ extern int GetStackFramesWithContext(void** result, uintptr_t* frames,
6969
int* sizes, int max_depth, int skip_count,
7070
const void* uc, int* min_dropped_frames);
7171

72+
// As above, but skips fix-ups for efficiency.
73+
extern int GetStackTraceNoFixup(void** result, int max_depth, int skip_count);
74+
7275
// Same as `absl::DefaultStackUnwinder`, but with an optional `frames` parameter
7376
// to allow callers to receive the raw stack frame addresses.
7477
// This is internal for now; do not depend on this externally.

0 commit comments

Comments
 (0)