Commit a5325e50 authored by Giuseppe Ottaviano's avatar Giuseppe Ottaviano Committed by Facebook Github Bot

Constify return value of get*ExceptionStackTraceStack

Summary: It's a read-only interface.

Reviewed By: philippv, luciang

Differential Revision: D19199710

fbshipit-source-id: 5e900edd35640cded45e6376eb0b81b9036bd792
parent c2281fce
......@@ -36,10 +36,10 @@ FOLLY_TLS StackTraceStack caughtExceptions;
} // namespace
// These functions are exported and may be found via dlsym(RTLD_NEXT, ...)
extern "C" StackTraceStack* getUncaughtExceptionStackTraceStack() {
extern "C" const StackTraceStack* getUncaughtExceptionStackTraceStack() {
return invalid ? nullptr : &uncaughtExceptions;
}
extern "C" StackTraceStack* getCaughtExceptionStackTraceStack() {
extern "C" const StackTraceStack* getCaughtExceptionStackTraceStack() {
return invalid ? nullptr : &caughtExceptions;
}
......
......@@ -37,9 +37,9 @@ using namespace ::folly::symbolizer;
using namespace __cxxabiv1;
extern "C" {
StackTraceStack* getCaughtExceptionStackTraceStack(void)
const StackTraceStack* getCaughtExceptionStackTraceStack(void)
__attribute__((__weak__));
typedef StackTraceStack* (*GetCaughtExceptionStackTraceStackType)();
typedef const StackTraceStack* (*GetCaughtExceptionStackTraceStackType)();
GetCaughtExceptionStackTraceStackType getCaughtExceptionStackTraceStackFn;
}
......@@ -150,7 +150,7 @@ std::vector<ExceptionInfo> getCurrentExceptions() {
return exceptions;
}
StackTraceStack* traceStack = nullptr;
const StackTraceStack* traceStack = nullptr;
if (!getCaughtExceptionStackTraceStackFn) {
static bool logged = false;
if (!logged) {
......@@ -167,7 +167,7 @@ std::vector<ExceptionInfo> getCurrentExceptions() {
}
}
StackTrace* trace = traceStack ? traceStack->top() : nullptr;
const StackTrace* trace = traceStack ? traceStack->top() : nullptr;
while (currentException) {
ExceptionInfo info;
// Dependent exceptions (thrown via std::rethrow_exception) aren't
......
......@@ -103,10 +103,21 @@ StackTrace* StackTraceStack::top() {
return state_[kTopIdx];
}
const StackTrace* StackTraceStack::top() const {
checkGuard();
return state_[kTopIdx];
}
StackTrace* StackTraceStack::next(StackTrace* p) {
checkGuard();
assert(p);
return static_cast<Node*>(p)->next;
}
const StackTrace* StackTraceStack::next(const StackTrace* p) const {
checkGuard();
assert(p);
return static_cast<const Node*>(p)->next;
}
} // namespace exception_tracer
} // namespace folly
......@@ -76,12 +76,14 @@ class StackTraceStack {
* Return the top stack trace, or nullptr if the stack is empty.
*/
StackTrace* top();
const StackTrace* top() const;
/**
* Return the stack trace following p, or nullptr if p is the bottom of
* the stack.
*/
StackTrace* next(StackTrace* p);
const StackTrace* next(const StackTrace* p) const;
private:
static constexpr size_t kTopIdx = kIsDebug ? 1 : 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment