1a6b96004SEric Christopher /*===-- llvm-c/ErrorHandling.h - Error Handling C Interface -------*- C -*-===*\ 2a6b96004SEric Christopher |* *| 32946cd70SChandler Carruth |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| 42946cd70SChandler Carruth |* Exceptions. *| 52946cd70SChandler Carruth |* See https://llvm.org/LICENSE.txt for license information. *| 62946cd70SChandler Carruth |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| 7a6b96004SEric Christopher |* *| 8a6b96004SEric Christopher |*===----------------------------------------------------------------------===*| 9a6b96004SEric Christopher |* *| 10a6b96004SEric Christopher |* This file defines the C interface to LLVM's error handling mechanism. *| 11a6b96004SEric Christopher |* *| 12a6b96004SEric Christopher \*===----------------------------------------------------------------------===*/ 13a6b96004SEric Christopher 145032b589SKazu Hirata #ifndef LLVM_C_ERRORHANDLING_H 155032b589SKazu Hirata #define LLVM_C_ERRORHANDLING_H 16a6b96004SEric Christopher 178c484050SDuncan P. N. Exon Smith #include "llvm-c/ExternC.h" 188c484050SDuncan P. N. Exon Smith 198c484050SDuncan P. N. Exon Smith LLVM_C_EXTERN_C_BEGIN 20a6b96004SEric Christopher 21*ad523cc3SMats Larsen /** 22*ad523cc3SMats Larsen * @addtogroup LLVMCError 23*ad523cc3SMats Larsen * 24*ad523cc3SMats Larsen * @{ 25*ad523cc3SMats Larsen */ 26*ad523cc3SMats Larsen 27a6b96004SEric Christopher typedef void (*LLVMFatalErrorHandler)(const char *Reason); 28a6b96004SEric Christopher 29a6b96004SEric Christopher /** 30a6b96004SEric Christopher * Install a fatal error handler. By default, if LLVM detects a fatal error, it 31a6b96004SEric Christopher * will call exit(1). This may not be appropriate in many contexts. For example, 32a6b96004SEric Christopher * doing exit(1) will bypass many crash reporting/tracing system tools. This 33a6b96004SEric Christopher * function allows you to install a callback that will be invoked prior to the 34a6b96004SEric Christopher * call to exit(1). 35a6b96004SEric Christopher */ 36a6b96004SEric Christopher void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler); 37a6b96004SEric Christopher 38a6b96004SEric Christopher /** 39a6b96004SEric Christopher * Reset the fatal error handler. This resets LLVM's fatal error handling 40a6b96004SEric Christopher * behavior to the default. 41a6b96004SEric Christopher */ 42a6b96004SEric Christopher void LLVMResetFatalErrorHandler(void); 43a6b96004SEric Christopher 44a6b96004SEric Christopher /** 45a6b96004SEric Christopher * Enable LLVM's built-in stack trace code. This intercepts the OS's crash 46a6b96004SEric Christopher * signals and prints which component of LLVM you were in at the time if the 47a6b96004SEric Christopher * crash. 48a6b96004SEric Christopher */ 49a6b96004SEric Christopher void LLVMEnablePrettyStackTrace(void); 50a6b96004SEric Christopher 51*ad523cc3SMats Larsen /** 52*ad523cc3SMats Larsen * @} 53*ad523cc3SMats Larsen */ 54*ad523cc3SMats Larsen 558c484050SDuncan P. N. Exon Smith LLVM_C_EXTERN_C_END 56a6b96004SEric Christopher 57a6b96004SEric Christopher #endif 58