]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
1 | //===- llvm/Support/Signals.h - Signal Handling support ----------*- C++ -*-===// |
2 | // | |
3 | // The LLVM Compiler Infrastructure | |
4 | // | |
5 | // This file is distributed under the University of Illinois Open Source | |
6 | // License. See LICENSE.TXT for details. | |
7 | // | |
8 | //===----------------------------------------------------------------------===// | |
9 | // | |
10 | // This file defines some helpful functions for dealing with the possibility of | |
11 | // unix signals occurring while your program is running. | |
12 | // | |
13 | //===----------------------------------------------------------------------===// | |
14 | ||
970d7e83 LB |
15 | #ifndef LLVM_SUPPORT_SIGNALS_H |
16 | #define LLVM_SUPPORT_SIGNALS_H | |
223e47cc LB |
17 | |
18 | #include "llvm/Support/Path.h" | |
970d7e83 | 19 | #include <cstdio> |
223e47cc LB |
20 | |
21 | namespace llvm { | |
22 | namespace sys { | |
23 | ||
24 | /// This function runs all the registered interrupt handlers, including the | |
25 | /// removal of files registered by RemoveFileOnSignal. | |
26 | void RunInterruptHandlers(); | |
27 | ||
28 | /// This function registers signal handlers to ensure that if a signal gets | |
29 | /// delivered that the named file is removed. | |
30 | /// @brief Remove a file if a fatal signal occurs. | |
1a4d82fc | 31 | bool RemoveFileOnSignal(StringRef Filename, std::string* ErrMsg = nullptr); |
223e47cc LB |
32 | |
33 | /// This function removes a file from the list of files to be removed on | |
34 | /// signal delivery. | |
1a4d82fc | 35 | void DontRemoveFileOnSignal(StringRef Filename); |
223e47cc LB |
36 | |
37 | /// When an error signal (such as SIBABRT or SIGSEGV) is delivered to the | |
38 | /// process, print a stack trace and then exit. | |
39 | /// @brief Print a stack trace if a fatal signal occurs. | |
40 | void PrintStackTraceOnErrorSignal(); | |
41 | ||
970d7e83 LB |
42 | /// \brief Print the stack trace using the given \c FILE object. |
43 | void PrintStackTrace(FILE *); | |
44 | ||
223e47cc LB |
45 | /// AddSignalHandler - Add a function to be called when an abort/kill signal |
46 | /// is delivered to the process. The handler can have a cookie passed to it | |
47 | /// to identify what instance of the handler it is. | |
48 | void AddSignalHandler(void (*FnPtr)(void *), void *Cookie); | |
49 | ||
50 | /// This function registers a function to be called when the user "interrupts" | |
51 | /// the program (typically by pressing ctrl-c). When the user interrupts the | |
52 | /// program, the specified interrupt function is called instead of the program | |
53 | /// being killed, and the interrupt function automatically disabled. Note | |
54 | /// that interrupt functions are not allowed to call any non-reentrant | |
55 | /// functions. An null interrupt function pointer disables the current | |
56 | /// installed function. Note also that the handler may be executed on a | |
57 | /// different thread on some platforms. | |
58 | /// @brief Register a function to be called when ctrl-c is pressed. | |
59 | void SetInterruptFunction(void (*IF)()); | |
60 | } // End sys namespace | |
61 | } // End llvm namespace | |
62 | ||
63 | #endif |