ExceptionTracerLib.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2016-present Facebook, Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #pragma once
  17. #include <exception>
  18. #include <typeinfo>
  19. namespace folly {
  20. namespace exception_tracer {
  21. namespace detail {
  22. /*
  23. * Unfortunately due to ambiguous nature of exception specifiers,
  24. * standard does not allow them to appear in typedefs or alias-declarations.
  25. * We, however, want callbacks to be exception safe.
  26. * This dummies are an ugly workaround that problem.
  27. */
  28. void dummyCxaThrow(void*, std::type_info*, void (*)(void*)) noexcept;
  29. void dummyCxaBeginCatch(void*) noexcept;
  30. void dummyCxaRethrow() noexcept;
  31. void dummyCxaEndCatch() noexcept;
  32. void dummyRethrowException(std::exception_ptr) noexcept;
  33. } // namespace detail
  34. using CxaThrowType = decltype(&detail::dummyCxaThrow);
  35. using CxaBeginCatchType = decltype(&detail::dummyCxaBeginCatch);
  36. using CxaRethrowType = decltype(&detail::dummyCxaRethrow);
  37. using CxaEndCatchType = decltype(&detail::dummyCxaEndCatch);
  38. using RethrowExceptionType = decltype(&detail::dummyRethrowException);
  39. void registerCxaThrowCallback(CxaThrowType callback);
  40. void registerCxaBeginCatchCallback(CxaBeginCatchType callback);
  41. void registerCxaRethrowCallback(CxaRethrowType callback);
  42. void registerCxaEndCatchCallback(CxaEndCatchType callback);
  43. void registerRethrowExceptionCallback(RethrowExceptionType callback);
  44. } // namespace exception_tracer
  45. } // namespace folly