Commit 934a40e2 authored by Robert Copeland's avatar Robert Copeland Committed by Facebook Github Bot

fix compilation of ExceptionTracer on ARM

Summary:
On ARM gcc, the unwind header defines exception_class as a char[8] rather
than a uint64_t.  Consequently compilation of exception_tracer fails on ARM
with the following error:

    .../folly/experimental/exception_tracer/ExceptionTracer.cpp: In function 'bool folly::exception_tracer::{anonymous}::isAbiCppException(const __cxxabiv1::__cxa_exception*)':
    .../folly/experimental/exception_tracer/ExceptionTracer.cpp:107:45: error: invalid operands of types 'const char [8]' and 'unsigned int' to binary 'operator&'
        return (exc->unwindHeader.exception_class & 0xffffffff) == cppClass;
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~

Construct a uint64_t for this platform.

Reviewed By: yfeldblum

Differential Revision: D13763587

fbshipit-source-id: 011cf13cdfcd1fffdeab8c384f7274f20faecbe5
parent 4c132efd
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <glog/logging.h> #include <glog/logging.h>
#include <folly/Portability.h>
#include <folly/String.h> #include <folly/String.h>
#include <folly/experimental/exception_tracer/ExceptionAbi.h> #include <folly/experimental/exception_tracer/ExceptionAbi.h>
#include <folly/experimental/exception_tracer/StackTrace.h> #include <folly/experimental/exception_tracer/StackTrace.h>
...@@ -99,12 +100,28 @@ namespace { ...@@ -99,12 +100,28 @@ namespace {
* exc doesn't actually point to a __cxa_exception structure, but * exc doesn't actually point to a __cxa_exception structure, but
* the offset of unwindHeader is correct, so exc->unwindHeader actually * the offset of unwindHeader is correct, so exc->unwindHeader actually
* returns a _Unwind_Exception object. Yeah, it's ugly like that. * returns a _Unwind_Exception object. Yeah, it's ugly like that.
*
* Type of exception_class depends on ABI: on some it is defined as a
* native endian uint64_t, on others a big endian char[8].
*/ */
bool isAbiCppException(const __cxa_exception* exc) { struct ArmAbiTag {};
struct AnyAbiTag {};
bool isAbiCppException(ArmAbiTag, const char (&klazz)[8]) {
return klazz[4] == 'C' && klazz[5] == '+' && klazz[6] == '+' &&
klazz[7] == '\0';
}
bool isAbiCppException(AnyAbiTag, const uint64_t& klazz) {
// The least significant four bytes must be "C++\0" // The least significant four bytes must be "C++\0"
static const uint64_t cppClass = 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; return (klazz & 0xffffffff) == cppClass;
}
bool isAbiCppException(const __cxa_exception* exc) {
using tag = std::conditional_t<kIsArchArm, ArmAbiTag, AnyAbiTag>;
return isAbiCppException(tag{}, exc->unwindHeader.exception_class);
} }
} // namespace } // namespace
......
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