blob: 4927349d898352e682a436fe1df2242891d06d5f [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001/*===-- llvm-c/ErrorHandling.h - Error Handling C Interface -------*- C -*-===*\
2|* *|
Andrew Walbran16937d02019-10-22 13:54:20 +01003|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
4|* Exceptions. *|
5|* See https://llvm.org/LICENSE.txt for license information. *|
6|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01007|* *|
8|*===----------------------------------------------------------------------===*|
9|* *|
10|* This file defines the C interface to LLVM's error handling mechanism. *|
11|* *|
12\*===----------------------------------------------------------------------===*/
13
14#ifndef LLVM_C_ERROR_HANDLING_H
15#define LLVM_C_ERROR_HANDLING_H
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21typedef void (*LLVMFatalErrorHandler)(const char *Reason);
22
23/**
24 * Install a fatal error handler. By default, if LLVM detects a fatal error, it
25 * will call exit(1). This may not be appropriate in many contexts. For example,
26 * doing exit(1) will bypass many crash reporting/tracing system tools. This
27 * function allows you to install a callback that will be invoked prior to the
28 * call to exit(1).
29 */
30void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler);
31
32/**
33 * Reset the fatal error handler. This resets LLVM's fatal error handling
34 * behavior to the default.
35 */
36void LLVMResetFatalErrorHandler(void);
37
38/**
39 * Enable LLVM's built-in stack trace code. This intercepts the OS's crash
40 * signals and prints which component of LLVM you were in at the time if the
41 * crash.
42 */
43void LLVMEnablePrettyStackTrace(void);
44
45#ifdef __cplusplus
46}
47#endif
48
49#endif