Skip to content

Commit

Permalink
Expose 'getMetaMap()' for the debugger to access the exception store.
Browse files Browse the repository at this point in the history
Summary: Expose 'getMetaMap()' so that the debugger can access the exceptions tracked using SmartExceptionTracer. This will enable to call 'co_exc_stack' command in lldb.

Reviewed By: Gownta

Differential Revision: D63010286

fbshipit-source-id: ab82526e57bb8a8a6c304675b24b2ddd5f7b7504
  • Loading branch information
mbucko authored and facebook-github-bot committed Oct 25, 2024
1 parent 16c2c41 commit 0859626
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
21 changes: 14 additions & 7 deletions folly/debugging/exception_tracer/SmartExceptionTracerSingleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@

#include <folly/debugging/exception_tracer/SmartExceptionTracerSingleton.h>

extern "C" {

folly::exception_tracer::detail::ExceptionMetaMap*
__folly_smart_exception_store{nullptr};
}

namespace folly::exception_tracer::detail {

Synchronized<F14FastMap<void*, std::unique_ptr<SynchronizedExceptionMeta>>>&
getMetaMap() {
// Leaky Meyers Singleton
static Indestructible<Synchronized<
F14FastMap<void*, std::unique_ptr<SynchronizedExceptionMeta>>>>
meta;
return *meta;
Synchronized<ExceptionMetaMap>& getMetaMap() {
static Indestructible<std::unique_ptr<Synchronized<ExceptionMetaMap>>> meta(
folly::factory_constructor, []() {
auto ret = std::make_unique<folly::Synchronized<ExceptionMetaMap>>();
__folly_smart_exception_store = &ret->unsafeGetUnlocked();
return ret;
});
return **meta;
}

static std::atomic_bool hookEnabled{false};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ struct ExceptionMeta {

using SynchronizedExceptionMeta = folly::Synchronized<ExceptionMeta>;

Synchronized<F14FastMap<void*, std::unique_ptr<SynchronizedExceptionMeta>>>&
getMetaMap();
using ExceptionMetaMap =
folly::F14VectorMap<void*, std::unique_ptr<SynchronizedExceptionMeta>>;

Synchronized<ExceptionMetaMap>& getMetaMap();

bool isSmartExceptionTracerHookEnabled();
void setSmartExceptionTracerHookEnabled(bool enabled);
Expand Down

0 comments on commit 0859626

Please sign in to comment.