Commit 2a0318b4 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Apply clang-format to folly/experimental/exception_tracer/

Summary: [Folly] Apply `clang-format` to `folly/experimental/exception_tracer/`.

Reviewed By: Orvid

Differential Revision: D5722994

fbshipit-source-id: 2e52c920119ba58d123aaffd59491d7561c37c17
parent f9d70dcd
......@@ -28,7 +28,7 @@ namespace __cxxabiv1 {
struct __cxa_exception {
std::type_info* exceptionType;
void (*exceptionDestructor) (void*);
void (*exceptionDestructor)(void*);
std::unexpected_handler unexpectedHandler;
std::terminate_handler terminateHandler;
__cxa_exception* nextException;
......
......@@ -77,7 +77,8 @@ std::vector<ExceptionStats> getExceptionStatistics() {
result.push_back(std::move(item.second));
}
std::sort(result.begin(),
std::sort(
result.begin(),
result.end(),
[](const ExceptionStats& lhs, const ExceptionStats& rhs) {
return lhs.count > rhs.count;
......@@ -133,7 +134,9 @@ void throwHandler(void*, std::type_info* exType, void (*)(void*)) noexcept {
}
struct Initializer {
Initializer() { registerCxaThrowCallback(throwHandler); }
Initializer() {
registerCxaThrowCallback(throwHandler);
}
};
Initializer initializer;
......
......@@ -61,8 +61,7 @@ void printExceptionInfo(
out << "(unknown type)";
}
out << " (" << info.frames.size()
<< (info.frames.size() == 1 ? " frame" : " frames")
<< ")\n";
<< (info.frames.size() == 1 ? " frame" : " frames") << ")\n";
try {
size_t frameCount = info.frames.size();
......@@ -104,9 +103,7 @@ namespace {
bool isAbiCppException(const __cxa_exception* exc) {
// The least significant four bytes must be "C++\0"
static const uint64_t cppClass =
((uint64_t)'C' << 24) |
((uint64_t)'+' << 16) |
((uint64_t)'+' << 8);
((uint64_t)'C' << 24) | ((uint64_t)'+' << 16) | ((uint64_t)'+' << 8);
return (exc->unwindHeader.exception_class & 0xffffffff) == cppClass;
}
......@@ -120,8 +117,7 @@ std::vector<ExceptionInfo> getCurrentExceptions() {
if (!getExceptionStackTraceStackFn) {
// Nope, see if it's in a shared library
getExceptionStackTraceStackFn =
(GetExceptionStackTraceStackType)dlsym(
getExceptionStackTraceStackFn = (GetExceptionStackTraceStackType)dlsym(
RTLD_NEXT, "getExceptionStackTraceStack");
}
}
......@@ -158,10 +154,9 @@ std::vector<ExceptionInfo> getCurrentExceptions() {
// standard ABI __cxa_exception objects, and are correctly labeled as
// such in the exception_class field. We could try to extract the
// primary exception type in horribly hacky ways, but, for now, nullptr.
info.type =
isAbiCppException(currentException) ?
currentException->exceptionType :
nullptr;
info.type = isAbiCppException(currentException)
? currentException->exceptionType
: nullptr;
if (traceStack) {
LOG_IF(DFATAL, !trace)
......
......@@ -47,7 +47,9 @@ template <typename Function>
class CallbackHolder {
public:
void registerCallback(Function f) {
SYNCHRONIZED(callbacks_) { callbacks_.push_back(std::move(f)); }
SYNCHRONIZED(callbacks_) {
callbacks_.push_back(std::move(f));
}
}
// always inline to enforce kInternalFramesNumber
......@@ -93,12 +95,13 @@ DECLARE_CALLBACK(RethrowException);
// calls need to go away. Everything else is messy though, so just
// #define it to an empty macro under Clang and be done with it.
#ifdef __clang__
# define __builtin_unreachable()
#define __builtin_unreachable()
#endif
namespace __cxxabiv1 {
void __cxa_throw(void* thrownException,
void __cxa_throw(
void* thrownException,
std::type_info* type,
void (*destructor)(void*)) {
static auto orig_cxa_throw =
......@@ -146,8 +149,8 @@ void rethrow_exception(std::exception_ptr ep) {
// TODO(tudorb): Dicey, as it relies on the fact that std::exception_ptr
// is typedef'ed to a type in namespace __exception_ptr
static auto orig_rethrow_exception =
reinterpret_cast<decltype(&rethrow_exception)>(
dlsym(RTLD_NEXT,
reinterpret_cast<decltype(&rethrow_exception)>(dlsym(
RTLD_NEXT,
"_ZSt17rethrow_exceptionNSt15__exception_ptr13exception_ptrE"));
getRethrowExceptionCallbacks().invoke(ep);
orig_rethrow_exception(ep);
......
......@@ -22,7 +22,8 @@
#include <folly/experimental/symbolizer/StackTrace.h>
namespace folly { namespace exception_tracer {
namespace folly {
namespace exception_tracer {
class StackTraceStack::Node : public StackTrace {
public:
......@@ -32,8 +33,8 @@ class StackTraceStack::Node : public StackTrace {
Node* next;
private:
Node() : next(nullptr) { }
~Node() { }
Node() : next(nullptr) {}
~Node() {}
};
auto StackTraceStack::Node::allocate() -> Node* {
......@@ -107,5 +108,5 @@ StackTrace* StackTraceStack::next(StackTrace* p) {
assert(p);
return static_cast<Node*>(p)->next;
}
}} // namespaces
} // namespace exception_tracer
} // namespace folly
......@@ -20,12 +20,13 @@
#include <cstddef>
#include <cstdint>
namespace folly { namespace exception_tracer {
namespace folly {
namespace exception_tracer {
constexpr size_t kMaxFrames = 500;
struct StackTrace {
StackTrace() : frameCount(0) { }
StackTrace() : frameCount(0) {}
size_t frameCount;
uintptr_t addresses[kMaxFrames];
......@@ -35,6 +36,7 @@ struct StackTrace {
// A StackTraceStack MUST be placed in zero-initialized memory.
class StackTraceStack {
class Node;
public:
/**
* Push the current stack trace onto the stack.
......@@ -64,7 +66,9 @@ class StackTraceStack {
/**
* Is the stack empty?
*/
bool empty() const { return !top_; }
bool empty() const {
return !top_;
}
/**
* Return the top stack trace, or nullptr if the stack is empty.
......@@ -94,5 +98,5 @@ class StackTraceStack {
uintptr_t guard2_;
#endif
};
}} // namespaces
} // namespace exception_tracer
} // namespace folly
......@@ -111,8 +111,8 @@ TEST(ExceptionCounter, multyThreads) {
{
std::unique_lock<std::mutex> lock(preparedMutex);
preparedBarrier.wait(lock,
[&]() { return preparedThreads == kNumThreads; });
preparedBarrier.wait(
lock, [&]() { return preparedThreads == kNumThreads; });
}
auto stats = getExceptionStatistics();
......
......@@ -47,7 +47,7 @@ BENCHMARK(ExceptionTracer, iters) {
constexpr size_t kNumThreads = 10;
threads.resize(10);
for (auto& t : threads) {
t = std::thread([iters] () { loop(iters); });
t = std::thread([iters]() { loop(iters); });
}
for (auto& t : threads) {
t.join();
......
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