LLVM 22.0.0git
|
#include "llvm/Support/Signals.h"
#include "DebugOptions.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/raw_ostream.h"
#include <array>
#include <cmath>
#include "Unix/Signals.inc"
Go to the source code of this file.
Classes | |
struct | CallbackAndCookie |
Functions | |
static std::array< CallbackAndCookie, MaxSignalHandlerCallbacks > & | CallBacksToRun () |
static void | insertSignalHandler (sys::SignalHandlerCallback FnPtr, void *Cookie) |
static bool | findModulesAndOffsets (void **StackTrace, int Depth, const char **Modules, intptr_t *Offsets, const char *MainExecutableName, StringSaver &StrPool) |
static FormattedNumber | format_ptr (void *PC) |
Format a pointer value as hexadecimal. | |
std::optional< SmallVector< std::pair< unsigned, std::string >, 0 > > | collectAddressSymbols (void **AddressList, unsigned AddressCount, const char *MainExecutableName, const std::string &LLVMSymbolizerPath) |
Reads a file Filename written by llvm-symbolizer containing function names and source locations for the addresses in AddressList and returns the strings in a vector of pairs, where the first pair element is the index of the corresponding entry in AddressList and the second is the symbolized frame, in a format based on the sanitizer stack trace printer, with the exception that it does not write out frame numbers (i.e. | |
ErrorOr< std::string > | getLLVMSymbolizerPath (StringRef Argv0={}) |
static LLVM_ATTRIBUTE_USED bool | printSymbolizedStackTrace (StringRef Argv0, void **StackTrace, int Depth, llvm::raw_ostream &OS) |
Helper that launches llvm-symbolizer and symbolizes a backtrace. | |
static bool | printMarkupContext (raw_ostream &OS, const char *MainExecutableName) |
static LLVM_ATTRIBUTE_USED bool | printMarkupStackTrace (StringRef Argv0, void **StackTrace, int Depth, raw_ostream &OS) |
Variables | |
static bool | DisableSymbolicationFlag = false |
static ManagedStatic< std::string > | CrashDiagnosticsDirectory |
constexpr char | DisableSymbolizationEnv [] = "LLVM_DISABLE_SYMBOLIZATION" |
constexpr char | LLVMSymbolizerPathEnv [] = "LLVM_SYMBOLIZER_PATH" |
constexpr char | EnableSymbolizerMarkupEnv [] = "LLVM_ENABLE_SYMBOLIZER_MARKUP" |
static constexpr size_t | MaxSignalHandlerCallbacks = 8 |
|
static |
Definition at line 91 of file Signals.cpp.
Referenced by insertSignalHandler(), and llvm::sys::RunSignalHandlers().
std::optional< SmallVector< std::pair< unsigned, std::string >, 0 > > collectAddressSymbols | ( | void ** | AddressList, |
unsigned | AddressCount, | ||
const char * | MainExecutableName, | ||
const std::string & | LLVMSymbolizerPath | ||
) |
Reads a file Filename
written by llvm-symbolizer containing function names and source locations for the addresses in AddressList
and returns the strings in a vector of pairs, where the first pair element is the index of the corresponding entry in AddressList and the second is the symbolized frame, in a format based on the sanitizer stack trace printer, with the exception that it does not write out frame numbers (i.e.
"#2 " for the third address), as it is not assumed that AddressList
corresponds to a single stack trace. There may be multiple returned entries for a single AddressList
entry if that frame address corresponds to one or more inlined frames; in this case, all frames for an address will appear contiguously and in-order.
Definition at line 151 of file Signals.cpp.
References Allocator, llvm::SmallString< InternalLen >::c_str(), llvm::sys::fs::createTemporaryFile(), llvm::SmallVectorTemplateCommon< T, typename >::data(), llvm::StringRef::empty(), llvm::sys::ExecuteAndWait(), findModulesAndOffsets(), llvm::format_hex(), format_ptr(), llvm::MemoryBuffer::getFile(), OS, llvm::StringRef::split(), llvm::StringRef::starts_with(), and llvm::SmallString< InternalLen >::str().
Referenced by printSymbolizedStackTrace().
|
static |
Referenced by collectAddressSymbols().
|
static |
Format a pointer value as hexadecimal.
Zero pad it out so its always the same width.
Definition at line 133 of file Signals.cpp.
References llvm::format_hex().
Referenced by collectAddressSymbols().
Definition at line 242 of file Signals.cpp.
Referenced by printSymbolizedStackTrace().
|
static |
Definition at line 111 of file Signals.cpp.
References CallBacksToRun(), CallbackAndCookie::Empty, CallbackAndCookie::Initialized, CallbackAndCookie::Initializing, and llvm::report_fatal_error().
|
static |
Referenced by printMarkupStackTrace().
|
static |
Definition at line 335 of file Signals.cpp.
References llvm::Depth, EnableSymbolizerMarkupEnv, llvm::sys::fs::exists(), llvm::format(), llvm::sys::fs::getMainExecutable(), I, OS, and printMarkupContext().
|
static |
Helper that launches llvm-symbolizer and symbolizes a backtrace.
Definition at line 259 of file Signals.cpp.
References collectAddressSymbols(), llvm::StringRef::contains(), llvm::Depth, DisableSymbolicationFlag, DisableSymbolizationEnv, llvm::sys::fs::exists(), llvm::formatv(), getLLVMSymbolizerPath(), llvm::sys::fs::getMainExecutable(), OS, and llvm::right_justify().
|
static |
Definition at line 44 of file Signals.cpp.
|
static |
Definition at line 43 of file Signals.cpp.
Referenced by printSymbolizedStackTrace().
|
constexpr |
Definition at line 72 of file Signals.cpp.
Referenced by printSymbolizedStackTrace().
|
constexpr |
Definition at line 74 of file Signals.cpp.
Referenced by printMarkupStackTrace().
|
constexpr |
Definition at line 73 of file Signals.cpp.
|
staticconstexpr |
Definition at line 86 of file Signals.cpp.