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; ...@@ -36,10 +36,10 @@ FOLLY_TLS StackTraceStack caughtExceptions;
} // namespace } // namespace
// These functions are exported and may be found via dlsym(RTLD_NEXT, ...) // 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; return invalid ? nullptr : &uncaughtExceptions;
} }
extern "C" StackTraceStack* getCaughtExceptionStackTraceStack() { extern "C" const StackTraceStack* getCaughtExceptionStackTraceStack() {
return invalid ? nullptr : &caughtExceptions; return invalid ? nullptr : &caughtExceptions;
} }
......
...@@ -37,9 +37,9 @@ using namespace ::folly::symbolizer; ...@@ -37,9 +37,9 @@ using namespace ::folly::symbolizer;
using namespace __cxxabiv1; using namespace __cxxabiv1;
extern "C" { extern "C" {
StackTraceStack* getCaughtExceptionStackTraceStack(void) const StackTraceStack* getCaughtExceptionStackTraceStack(void)
__attribute__((__weak__)); __attribute__((__weak__));
typedef StackTraceStack* (*GetCaughtExceptionStackTraceStackType)(); typedef const StackTraceStack* (*GetCaughtExceptionStackTraceStackType)();
GetCaughtExceptionStackTraceStackType getCaughtExceptionStackTraceStackFn; GetCaughtExceptionStackTraceStackType getCaughtExceptionStackTraceStackFn;
} }
...@@ -150,7 +150,7 @@ std::vector<ExceptionInfo> getCurrentExceptions() { ...@@ -150,7 +150,7 @@ std::vector<ExceptionInfo> getCurrentExceptions() {
return exceptions; return exceptions;
} }
StackTraceStack* traceStack = nullptr; const StackTraceStack* traceStack = nullptr;
if (!getCaughtExceptionStackTraceStackFn) { if (!getCaughtExceptionStackTraceStackFn) {
static bool logged = false; static bool logged = false;
if (!logged) { if (!logged) {
...@@ -167,7 +167,7 @@ std::vector<ExceptionInfo> getCurrentExceptions() { ...@@ -167,7 +167,7 @@ std::vector<ExceptionInfo> getCurrentExceptions() {
} }
} }
StackTrace* trace = traceStack ? traceStack->top() : nullptr; const StackTrace* trace = traceStack ? traceStack->top() : nullptr;
while (currentException) { while (currentException) {
ExceptionInfo info; ExceptionInfo info;
// Dependent exceptions (thrown via std::rethrow_exception) aren't // Dependent exceptions (thrown via std::rethrow_exception) aren't
......
...@@ -103,10 +103,21 @@ StackTrace* StackTraceStack::top() { ...@@ -103,10 +103,21 @@ StackTrace* StackTraceStack::top() {
return state_[kTopIdx]; return state_[kTopIdx];
} }
const StackTrace* StackTraceStack::top() const {
checkGuard();
return state_[kTopIdx];
}
StackTrace* StackTraceStack::next(StackTrace* p) { StackTrace* StackTraceStack::next(StackTrace* p) {
checkGuard(); checkGuard();
assert(p); assert(p);
return static_cast<Node*>(p)->next; 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 exception_tracer
} // namespace folly } // namespace folly
...@@ -76,12 +76,14 @@ class StackTraceStack { ...@@ -76,12 +76,14 @@ class StackTraceStack {
* Return the top stack trace, or nullptr if the stack is empty. * Return the top stack trace, or nullptr if the stack is empty.
*/ */
StackTrace* top(); StackTrace* top();
const StackTrace* top() const;
/** /**
* Return the stack trace following p, or nullptr if p is the bottom of * Return the stack trace following p, or nullptr if p is the bottom of
* the stack. * the stack.
*/ */
StackTrace* next(StackTrace* p); StackTrace* next(StackTrace* p);
const StackTrace* next(const StackTrace* p) const;
private: private:
static constexpr size_t kTopIdx = kIsDebug ? 1 : 0; 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