clang-tools 19.0.0git
Public Types | Public Member Functions | Static Public Member Functions | List of all members
clang::clangd::ThreadCrashReporter Class Reference

Allows setting per-thread abort/kill signal callbacks, to print additional information about the crash depending on which thread got signalled. More...

#include <ThreadCrashReporter.h>

Public Types

using SignalCallback = llvm::unique_function< void(void)>
 

Public Member Functions

 ThreadCrashReporter (SignalCallback ThreadLocalCallback)
 Registers the callback as the first one in thread-local callback chain.
 
 ~ThreadCrashReporter ()
 Resets the current thread's callback to nullptr.
 
 ThreadCrashReporter (ThreadCrashReporter &&RHS)=delete
 Moves are disabled to ease nesting and escaping considerations.
 
 ThreadCrashReporter (const ThreadCrashReporter &)=delete
 
ThreadCrashReporteroperator= (ThreadCrashReporter &&)=delete
 
ThreadCrashReporteroperator= (const ThreadCrashReporter &)=delete
 

Static Public Member Functions

static void runCrashHandlers ()
 Calls all currently-active ThreadCrashReporters for the current thread.
 

Detailed Description

Allows setting per-thread abort/kill signal callbacks, to print additional information about the crash depending on which thread got signalled.

Definition at line 19 of file ThreadCrashReporter.h.

Member Typedef Documentation

◆ SignalCallback

using clang::clangd::ThreadCrashReporter::SignalCallback = llvm::unique_function<void(void)>

Definition at line 21 of file ThreadCrashReporter.h.

Constructor & Destructor Documentation

◆ ThreadCrashReporter() [1/3]

clang::clangd::ThreadCrashReporter::ThreadCrashReporter ( SignalCallback  ThreadLocalCallback)

Registers the callback as the first one in thread-local callback chain.

Asserts if the current thread's callback is already set. The callback is likely to be invoked in a signal handler. Most LLVM signal handling is not strictly async-signal-safe. However reporters should avoid accessing data structures likely to be in a bad state on crash.

Definition at line 35 of file ThreadCrashReporter.cpp.

References clang::clangd::CurrentReporter.

◆ ~ThreadCrashReporter()

clang::clangd::ThreadCrashReporter::~ThreadCrashReporter ( )

Resets the current thread's callback to nullptr.

Definition at line 44 of file ThreadCrashReporter.cpp.

References clang::clangd::CurrentReporter.

◆ ThreadCrashReporter() [2/3]

clang::clangd::ThreadCrashReporter::ThreadCrashReporter ( ThreadCrashReporter &&  RHS)
delete

Moves are disabled to ease nesting and escaping considerations.

◆ ThreadCrashReporter() [3/3]

clang::clangd::ThreadCrashReporter::ThreadCrashReporter ( const ThreadCrashReporter )
delete

Member Function Documentation

◆ operator=() [1/2]

ThreadCrashReporter & clang::clangd::ThreadCrashReporter::operator= ( const ThreadCrashReporter )
delete

◆ operator=() [2/2]

ThreadCrashReporter & clang::clangd::ThreadCrashReporter::operator= ( ThreadCrashReporter &&  )
delete

◆ runCrashHandlers()

void clang::clangd::ThreadCrashReporter::runCrashHandlers ( )
static

Calls all currently-active ThreadCrashReporters for the current thread.

To be called from sys::AddSignalHandler() callback. Any signal filtering is the responsibility of the caller. While this function is intended to be called from signal handlers, it is not strictly async-signal-safe - see constructor comment.

When several reporters are nested, the callbacks are called in LIFO order.

Definition at line 17 of file ThreadCrashReporter.cpp.

References clang::clangd::CurrentReporter.

Referenced by clang::clangd::clangdMain().


The documentation for this class was generated from the following files: