38 #pragma comment(lib, "psapi.lib") 48 #pragma GCC diagnostic ignored "-Wformat" 49 #pragma GCC diagnostic ignored "-Wformat-extra-args" 51 #if !defined(__MINGW64_VERSION_MAJOR) 56 typedef struct _IMAGEHLP_LINE64 {
62 } IMAGEHLP_LINE64, *PIMAGEHLP_LINE64;
64 typedef struct _IMAGEHLP_SYMBOL64 {
71 } IMAGEHLP_SYMBOL64, *PIMAGEHLP_SYMBOL64;
73 typedef struct _tagADDRESS64 {
77 } ADDRESS64, *LPADDRESS64;
79 typedef struct _KDHELP64 {
81 DWORD ThCallbackStack;
82 DWORD ThCallbackBStore;
85 DWORD64 KiCallUserMode;
86 DWORD64 KeUserCallbackDispatcher;
87 DWORD64 SystemRangeStart;
88 DWORD64 KiUserExceptionDispatcher;
92 } KDHELP64, *PKDHELP64;
94 typedef struct _tagSTACKFRAME64 {
100 PVOID FuncTableEntry;
106 } STACKFRAME64, *LPSTACKFRAME64;
107 #endif // !defined(__MINGW64_VERSION_MAJOR) 108 #endif // __MINGW32__ 110 typedef BOOL (__stdcall *PREAD_PROCESS_MEMORY_ROUTINE64)(HANDLE hProcess,
111 DWORD64 qwBaseAddress, PVOID lpBuffer,
DWORD nSize,
112 LPDWORD lpNumberOfBytesRead);
114 typedef PVOID (__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE64)( HANDLE ahProcess,
117 typedef DWORD64 (__stdcall *PGET_MODULE_BASE_ROUTINE64)(HANDLE hProcess,
120 typedef DWORD64 (__stdcall *PTRANSLATE_ADDRESS_ROUTINE64)(HANDLE hProcess,
121 HANDLE hThread, LPADDRESS64 lpaddr);
123 typedef BOOL(WINAPI *fpMiniDumpWriteDump)(HANDLE,
DWORD, HANDLE, MINIDUMP_TYPE,
124 PMINIDUMP_EXCEPTION_INFORMATION,
125 PMINIDUMP_USER_STREAM_INFORMATION,
126 PMINIDUMP_CALLBACK_INFORMATION);
127 static fpMiniDumpWriteDump fMiniDumpWriteDump;
129 typedef BOOL (WINAPI *fpStackWalk64)(
DWORD, HANDLE, HANDLE, LPSTACKFRAME64,
130 PVOID, PREAD_PROCESS_MEMORY_ROUTINE64,
131 PFUNCTION_TABLE_ACCESS_ROUTINE64,
132 PGET_MODULE_BASE_ROUTINE64,
133 PTRANSLATE_ADDRESS_ROUTINE64);
134 static fpStackWalk64 fStackWalk64;
136 typedef DWORD64 (WINAPI *fpSymGetModuleBase64)(HANDLE, DWORD64);
137 static fpSymGetModuleBase64 fSymGetModuleBase64;
139 typedef BOOL (WINAPI *fpSymGetSymFromAddr64)(HANDLE, DWORD64,
140 PDWORD64, PIMAGEHLP_SYMBOL64);
141 static fpSymGetSymFromAddr64 fSymGetSymFromAddr64;
143 typedef BOOL (WINAPI *fpSymGetLineFromAddr64)(HANDLE, DWORD64,
144 PDWORD, PIMAGEHLP_LINE64);
145 static fpSymGetLineFromAddr64 fSymGetLineFromAddr64;
147 typedef BOOL(WINAPI *fpSymGetModuleInfo64)(HANDLE hProcess, DWORD64 dwAddr,
148 PIMAGEHLP_MODULE64 ModuleInfo);
149 static fpSymGetModuleInfo64 fSymGetModuleInfo64;
151 typedef PVOID (WINAPI *fpSymFunctionTableAccess64)(HANDLE, DWORD64);
152 static fpSymFunctionTableAccess64 fSymFunctionTableAccess64;
154 typedef DWORD (WINAPI *fpSymSetOptions)(
DWORD);
155 static fpSymSetOptions fSymSetOptions;
157 typedef BOOL (WINAPI *fpSymInitialize)(HANDLE, PCSTR, BOOL);
158 static fpSymInitialize fSymInitialize;
160 typedef BOOL (WINAPI *fpEnumerateLoadedModules)(HANDLE,PENUMLOADED_MODULES_CALLBACK64,PVOID);
161 static fpEnumerateLoadedModules fEnumerateLoadedModules;
163 static bool load64BitDebugHelp(
void) {
164 HMODULE hLib = ::LoadLibraryW(L
"Dbghelp.dll");
166 fMiniDumpWriteDump = (fpMiniDumpWriteDump)
167 ::GetProcAddress(hLib,
"MiniDumpWriteDump");
168 fStackWalk64 = (fpStackWalk64)
169 ::GetProcAddress(hLib,
"StackWalk64");
170 fSymGetModuleBase64 = (fpSymGetModuleBase64)
171 ::GetProcAddress(hLib,
"SymGetModuleBase64");
172 fSymGetSymFromAddr64 = (fpSymGetSymFromAddr64)
173 ::GetProcAddress(hLib,
"SymGetSymFromAddr64");
174 fSymGetLineFromAddr64 = (fpSymGetLineFromAddr64)
175 ::GetProcAddress(hLib,
"SymGetLineFromAddr64");
176 fSymGetModuleInfo64 = (fpSymGetModuleInfo64)
177 ::GetProcAddress(hLib,
"SymGetModuleInfo64");
178 fSymFunctionTableAccess64 = (fpSymFunctionTableAccess64)
179 ::GetProcAddress(hLib,
"SymFunctionTableAccess64");
180 fSymSetOptions = (fpSymSetOptions)::GetProcAddress(hLib,
"SymSetOptions");
181 fSymInitialize = (fpSymInitialize)::GetProcAddress(hLib,
"SymInitialize");
182 fEnumerateLoadedModules = (fpEnumerateLoadedModules)
183 ::GetProcAddress(hLib,
"EnumerateLoadedModules64");
185 return fStackWalk64 && fSymInitialize && fSymSetOptions && fMiniDumpWriteDump;
188 using namespace llvm;
191 static LONG WINAPI LLVMUnhandledExceptionFilter(LPEXCEPTION_POINTERS ep);
192 static BOOL WINAPI LLVMConsoleCtrlHandler(
DWORD dwCtrlType);
195 static void (*InterruptFunction)() = 0;
197 static std::vector<std::string> *FilesToRemove = NULL;
198 static bool RegisteredUnhandledExceptionFilter =
false;
199 static bool CleanupExecuted =
false;
200 static PTOP_LEVEL_EXCEPTION_FILTER OldFilter = NULL;
205 static CRITICAL_SECTION CriticalSection;
206 static bool CriticalSectionInitialized =
false;
213 #elif defined(_M_ARM64) 215 #elif defined(_M_IX86) 217 #elif defined(_M_ARM) 225 HANDLE hProcess, HANDLE hThread,
226 STACKFRAME64 &StackFrameOrig,
227 CONTEXT *ContextOrig) {
229 STACKFRAME64 StackFrame = StackFrameOrig;
235 CONTEXT
Context = *ContextOrig;
236 Context.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER;
238 static void *StackTrace[256];
240 while (fStackWalk64(NativeMachineType, hProcess, hThread, &StackFrame,
241 &Context, 0, fSymFunctionTableAccess64,
242 fSymGetModuleBase64, 0)) {
243 if (StackFrame.AddrFrame.Offset == 0)
245 StackTrace[Depth++] = (
void *)(uintptr_t)StackFrame.AddrPC.Offset;
254 struct FindModuleData {
257 const char **Modules;
263 static BOOL CALLBACK findModuleCallback(PCSTR ModuleName,
264 DWORD64 ModuleBase, ULONG ModuleSize,
266 FindModuleData *
Data = (FindModuleData*)VoidData;
269 for (
int I = 0;
I < Data->Depth;
I++) {
270 if (Data->Modules[
I])
273 if (Beg <= Addr && Addr < End) {
274 Data->Modules[
I] = Data->StrPool->save(ModuleName).data();
275 Data->Offsets[
I] = Addr - Beg;
283 const char *MainExecutableName,
285 if (!fEnumerateLoadedModules)
288 Data.StackTrace = StackTrace;
290 Data.Modules = Modules;
292 Data.StrPool = &StrPool;
293 fEnumerateLoadedModules(GetCurrentProcess(), findModuleCallback, &Data);
298 HANDLE hThread, STACKFRAME64 &StackFrame,
301 fSymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_LOAD_LINES);
302 fSymInitialize(hProcess, NULL, TRUE);
307 if (printStackTraceWithLLVMSymbolizer(OS, hProcess, hThread, StackFrame,
313 if (!fStackWalk64(NativeMachineType, hProcess, hThread, &StackFrame,
314 Context, 0, fSymFunctionTableAccess64,
315 fSymGetModuleBase64, 0)) {
319 if (StackFrame.AddrFrame.Offset == 0)
322 using namespace llvm;
324 DWORD64 PC = StackFrame.AddrPC.Offset;
325 #if defined(_M_X64) || defined(_M_ARM64) 326 OS <<
format(
"0x%016llX", PC);
327 #elif defined(_M_IX86) || defined(_M_ARM) 328 OS <<
format(
"0x%08lX", static_cast<DWORD>(PC));
332 #if defined(_M_X64) || defined(_M_ARM64) 333 OS <<
format(
" (0x%016llX 0x%016llX 0x%016llX 0x%016llX)",
334 StackFrame.Params[0], StackFrame.Params[1], StackFrame.Params[2],
335 StackFrame.Params[3]);
336 #elif defined(_M_IX86) || defined(_M_ARM) 337 OS <<
format(
" (0x%08lX 0x%08lX 0x%08lX 0x%08lX)",
338 static_cast<DWORD>(StackFrame.Params[0]),
339 static_cast<DWORD>(StackFrame.Params[1]),
340 static_cast<DWORD>(StackFrame.Params[2]),
341 static_cast<DWORD>(StackFrame.Params[3]));
344 if (!fSymGetModuleBase64(hProcess, PC)) {
345 OS <<
" <unknown module>\n";
351 IMAGEHLP_SYMBOL64 *symbol =
reinterpret_cast<IMAGEHLP_SYMBOL64 *
>(buffer);
352 memset(symbol, 0,
sizeof(IMAGEHLP_SYMBOL64));
353 symbol->SizeOfStruct =
sizeof(IMAGEHLP_SYMBOL64);
354 symbol->MaxNameLength = 512 -
sizeof(IMAGEHLP_SYMBOL64);
357 if (!fSymGetSymFromAddr64(hProcess, PC, &dwDisp, symbol)) {
364 OS <<
format(
", %s() + 0x%llX bytes(s)", (
const char*)symbol->Name,
367 OS <<
format(
", %s", (
const char*)symbol->Name);
370 IMAGEHLP_LINE64 line = {};
372 line.SizeOfStruct =
sizeof(line);
373 if (fSymGetLineFromAddr64(hProcess, PC, &dwLineDisp, &line)) {
374 OS <<
format(
", %s, line %lu", line.FileName, line.LineNumber);
376 OS <<
format(
" + 0x%lX byte(s)", dwLineDisp);
395 AvoidMessageBoxHook(
int ReportType,
char *Message,
int *
Return) {
407 extern "C" void HandleAbort(
int Sig) {
408 if (Sig == SIGABRT) {
413 static void InitializeThreading() {
414 if (CriticalSectionInitialized)
419 InitializeCriticalSection(&CriticalSection);
420 CriticalSectionInitialized =
true;
423 static void RegisterHandler() {
427 if (!load64BitDebugHelp()) {
428 assert(
false &&
"These APIs should always be available");
432 if (RegisteredUnhandledExceptionFilter) {
433 EnterCriticalSection(&CriticalSection);
437 InitializeThreading();
441 EnterCriticalSection(&CriticalSection);
443 RegisteredUnhandledExceptionFilter =
true;
444 OldFilter = SetUnhandledExceptionFilter(LLVMUnhandledExceptionFilter);
445 SetConsoleCtrlHandler(LLVMConsoleCtrlHandler, TRUE);
455 if (CleanupExecuted) {
457 *ErrMsg =
"Process terminating -- cannot register for removal";
461 if (FilesToRemove == NULL)
462 FilesToRemove =
new std::vector<std::string>;
464 FilesToRemove->push_back(Filename);
466 LeaveCriticalSection(&CriticalSection);
472 if (FilesToRemove == NULL)
477 std::vector<std::string>::reverse_iterator
I =
479 if (I != FilesToRemove->rend())
480 FilesToRemove->erase(I.base()-1);
482 LeaveCriticalSection(&CriticalSection);
487 signal(SIGABRT, HandleAbort);
492 _set_abort_behavior(0, _WRITE_ABORT_MSG);
494 _set_abort_behavior(0, _CALL_REPORTFAULT);
495 _CrtSetReportHook(AvoidMessageBoxHook);
499 SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX |
500 SEM_NOOPENFILEERRORBOX);
501 _set_error_mode(_OUT_TO_STDERR);
507 bool DisableCrashReporting) {
510 if (DisableCrashReporting || getenv(
"LLVM_DISABLE_CRASH_REPORT"))
511 Process::PreventCoreFiles();
515 LeaveCriticalSection(&CriticalSection);
519 #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) 522 extern "C" VOID WINAPI RtlCaptureContext(PCONTEXT ContextRecord);
526 STACKFRAME64 StackFrame = {};
527 CONTEXT Context = {};
528 ::RtlCaptureContext(&Context);
530 StackFrame.AddrPC.Offset = Context.Rip;
531 StackFrame.AddrStack.Offset = Context.Rsp;
532 StackFrame.AddrFrame.Offset = Context.Rbp;
533 #elif defined(_M_IX86) 534 StackFrame.AddrPC.Offset = Context.Eip;
535 StackFrame.AddrStack.Offset = Context.Esp;
536 StackFrame.AddrFrame.Offset = Context.Ebp;
537 #elif defined(_M_ARM64) 538 StackFrame.AddrPC.Offset = Context.Pc;
539 StackFrame.AddrStack.Offset = Context.Sp;
540 StackFrame.AddrFrame.Offset = Context.Fp;
541 #elif defined(_M_ARM) 542 StackFrame.AddrPC.Offset = Context.Pc;
543 StackFrame.AddrStack.Offset = Context.Sp;
544 StackFrame.AddrFrame.Offset = Context.R11;
546 StackFrame.AddrPC.Mode = AddrModeFlat;
547 StackFrame.AddrStack.Mode = AddrModeFlat;
548 StackFrame.AddrFrame.Mode = AddrModeFlat;
549 PrintStackTraceForThread(OS, GetCurrentProcess(), GetCurrentThread(),
550 StackFrame, &Context);
556 InterruptFunction =
IF;
557 LeaveCriticalSection(&CriticalSection);
568 LeaveCriticalSection(&CriticalSection);
571 static void Cleanup() {
575 EnterCriticalSection(&CriticalSection);
579 CleanupExecuted =
true;
582 if (FilesToRemove != NULL)
583 while (!FilesToRemove->empty()) {
585 FilesToRemove->pop_back();
588 LeaveCriticalSection(&CriticalSection);
596 InitializeThreading();
603 static HKEY FindWERKey(
const llvm::Twine &RegistryLocation) {
605 if (ERROR_SUCCESS != ::RegOpenKeyExA(HKEY_LOCAL_MACHINE,
606 RegistryLocation.
str().c_str(), 0,
607 KEY_QUERY_VALUE | KEY_READ, &
Key))
617 static bool GetDumpFolder(HKEY Key,
619 using llvm::sys::windows::UTF16ToUTF8;
624 DWORD BufferLengthBytes = 0;
626 if (ERROR_SUCCESS != ::RegGetValueW(Key, 0, L
"DumpFolder", REG_EXPAND_SZ,
627 NULL, NULL, &BufferLengthBytes))
632 if (ERROR_SUCCESS != ::RegGetValueW(Key, 0, L
"DumpFolder", REG_EXPAND_SZ,
633 NULL, Buffer.data(), &BufferLengthBytes))
636 DWORD ExpandBufferSize = ::ExpandEnvironmentStringsW(Buffer.data(), NULL, 0);
638 if (!ExpandBufferSize)
643 if (ExpandBufferSize != ::ExpandEnvironmentStringsW(Buffer.data(),
648 if (UTF16ToUTF8(ExpandBuffer.data(), ExpandBufferSize - 1, ResultDirectory))
667 static bool GetDumpType(HKEY Key, MINIDUMP_TYPE &ResultType) {
672 DWORD TypeSize =
sizeof(DumpType);
673 if (ERROR_SUCCESS != ::RegGetValueW(Key, NULL, L
"DumpType", RRF_RT_REG_DWORD,
681 if (ERROR_SUCCESS != ::RegGetValueW(Key, NULL, L
"CustomDumpFlags",
682 RRF_RT_REG_DWORD, NULL, &Flags,
686 ResultType =
static_cast<MINIDUMP_TYPE
>(Flags);
690 ResultType = MiniDumpNormal;
693 ResultType = MiniDumpWithFullMemory;
706 static std::error_code WINAPI
707 WriteWindowsDumpFile(PMINIDUMP_EXCEPTION_INFORMATION ExceptionInfo) {
708 using namespace llvm;
714 if (MainExecutableName.empty()) {
728 "SOFTWARE\\Microsoft\\Windows\\Windows Error Reporting\\LocalDumps";
732 ScopedRegHandle DefaultLocalDumpsKey(FindWERKey(LocalDumpsRegistryLocation));
738 FindWERKey(
Twine(LocalDumpsRegistryLocation) +
"\\" + ProgramName));
744 MINIDUMP_TYPE DumpType;
745 if (!GetDumpType(AppSpecificKey, DumpType))
746 if (!GetDumpType(DefaultLocalDumpsKey, DumpType))
747 DumpType = MiniDumpNormal;
754 bool ExplicitDumpDirectorySet =
true;
756 if (!GetDumpFolder(AppSpecificKey, DumpDirectory))
757 if (!GetDumpFolder(DefaultLocalDumpsKey, DumpDirectory))
758 ExplicitDumpDirectorySet =
false;
763 if (ExplicitDumpDirectorySet) {
767 Twine(DumpDirectory) +
"\\" + ProgramName +
".%%%%%%.dmp", FD,
770 }
else if (std::error_code EC =
777 if (!fMiniDumpWriteDump(::GetCurrentProcess(), ::GetCurrentProcessId(),
778 FileHandle, DumpType, ExceptionInfo, NULL, NULL))
781 llvm::errs() <<
"Wrote crash dump file \"" << DumpPath <<
"\"\n";
782 return std::error_code();
785 static LONG WINAPI LLVMUnhandledExceptionFilter(LPEXCEPTION_POINTERS ep) {
793 MINIDUMP_EXCEPTION_INFORMATION ExceptionInfo;
794 ExceptionInfo.ThreadId = ::GetCurrentThreadId();
795 ExceptionInfo.ExceptionPointers = ep;
796 ExceptionInfo.ClientPointers = FALSE;
798 if (std::error_code EC = WriteWindowsDumpFile(&ExceptionInfo))
799 llvm::errs() <<
"Could not write crash dump file: " <<
EC.message()
804 STACKFRAME64 StackFrame = {};
807 StackFrame.AddrPC.Offset = ep->ContextRecord->Rip;
808 StackFrame.AddrPC.Mode = AddrModeFlat;
809 StackFrame.AddrStack.Offset = ep->ContextRecord->Rsp;
810 StackFrame.AddrStack.Mode = AddrModeFlat;
811 StackFrame.AddrFrame.Offset = ep->ContextRecord->Rbp;
812 StackFrame.AddrFrame.Mode = AddrModeFlat;
813 #elif defined(_M_IX86) 814 StackFrame.AddrPC.Offset = ep->ContextRecord->Eip;
815 StackFrame.AddrPC.Mode = AddrModeFlat;
816 StackFrame.AddrStack.Offset = ep->ContextRecord->Esp;
817 StackFrame.AddrStack.Mode = AddrModeFlat;
818 StackFrame.AddrFrame.Offset = ep->ContextRecord->Ebp;
819 StackFrame.AddrFrame.Mode = AddrModeFlat;
820 #elif defined(_M_ARM64) || defined(_M_ARM) 821 StackFrame.AddrPC.Offset = ep->ContextRecord->Pc;
822 StackFrame.AddrPC.Mode = AddrModeFlat;
823 StackFrame.AddrStack.Offset = ep->ContextRecord->Sp;
824 StackFrame.AddrStack.Mode = AddrModeFlat;
825 #if defined(_M_ARM64) 826 StackFrame.AddrFrame.Offset = ep->ContextRecord->Fp;
828 StackFrame.AddrFrame.Offset = ep->ContextRecord->R11;
830 StackFrame.AddrFrame.Mode = AddrModeFlat;
833 HANDLE hProcess = GetCurrentProcess();
834 HANDLE hThread = GetCurrentThread();
835 PrintStackTraceForThread(
llvm::errs(), hProcess, hThread, StackFrame,
838 _exit(ep->ExceptionRecord->ExceptionCode);
841 static BOOL WINAPI LLVMConsoleCtrlHandler(
DWORD dwCtrlType) {
843 EnterCriticalSection(&CriticalSection);
848 void (*
IF)() = InterruptFunction;
849 InterruptFunction = 0;
855 LeaveCriticalSection(&CriticalSection);
860 LeaveCriticalSection(&CriticalSection);
869 #pragma GCC diagnostic warning "-Wformat" 870 #pragma GCC diagnostic warning "-Wformat-extra-args" std::error_code create_directories(const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
Create all the non-existent directories in path.
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
This class represents lattice values for constants.
std::error_code createUniqueFile(const Twine &Model, int &ResultFD, SmallVectorImpl< char > &ResultPath, unsigned Mode=all_read|all_write)
Create a uniquely named file.
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
void(*)(void *) SignalHandlerCallback
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
static bool AreCoreFilesPrevented()
true if PreventCoreFiles has been called, false otherwise.
void DisableSystemDialogsOnCrash()
Disable all system dialog boxes that appear when the process crashes.
static bool findModulesAndOffsets(void **StackTrace, int Depth, const char **Modules, intptr_t *Offsets, const char *MainExecutableName, StringSaver &StrPool)
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
auto reverse(ContainerTy &&C, typename std::enable_if< has_rbegin< ContainerTy >::value >::type *=nullptr) -> decltype(make_range(C.rbegin(), C.rend()))
#define LLVM_BUILTIN_TRAP
LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands to an expression which states that ...
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
std::string getMainExecutable(const char *argv0, void *MainExecAddr)
Return the path to the main executable, given the value of argv[0] from program startup and the addre...
void PrintStackTraceOnErrorSignal(StringRef Argv0, bool DisableCrashReporting=false)
When an error signal (such as SIGABRT or SIGSEGV) is delivered to the process, print a stack trace an...
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
void PrintStackTrace(raw_ostream &OS)
Print the stack trace using the given raw_ostream object.
void RunInterruptHandlers()
This function runs all the registered interrupt handlers, including the removal of files registered b...
std::error_code mapWindowsError(unsigned EV)
void DontRemoveFileOnSignal(StringRef Filename)
This function removes a file from the list of files to be removed on signal delivery.
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.
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
constexpr size_t array_lengthof(T(&)[N])
Find the length of an array.
bool RemoveFileOnSignal(StringRef Filename, std::string *ErrMsg=nullptr)
This function registers signal handlers to ensure that if a signal gets delivered that the named file...
Saves strings in the provided stable storage and returns a StringRef with a stable character pointer...
Provides a library for accessing information about this process and other processes on the operating ...
StringRef filename(StringRef path, Style style=Style::native)
Get filename.
std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, int &ResultFD, SmallVectorImpl< char > &ResultPath)
Create a file in the system temporary directory.
void AddSignalHandler(SignalHandlerCallback FnPtr, void *Cookie)
Add a function to be called when an abort/kill signal is delivered to the process.
std::string str() const
Return the twine contents as a std::string.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void insertSignalHandler(sys::SignalHandlerCallback FnPtr, void *Cookie)
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
#define LLVM_ATTRIBUTE_UNUSED
void SetInterruptFunction(void(*IF)())
This function registers a function to be called when the user "interrupts" the program (typically by ...