2010-11-29 20:44:50 +01:00
|
|
|
//===- llvm/Support/Signals.h - Signal Handling support ----------*- C++ -*-===//
|
2005-04-21 22:48:15 +02:00
|
|
|
//
|
2004-05-27 07:30:18 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:59:42 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 22:48:15 +02:00
|
|
|
//
|
2004-05-27 07:30:18 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines some helpful functions for dealing with the possibility of
|
2011-04-15 07:18:47 +02:00
|
|
|
// unix signals occurring while your program is running.
|
2004-05-27 07:30:18 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-01-10 01:45:19 +01:00
|
|
|
#ifndef LLVM_SUPPORT_SIGNALS_H
|
|
|
|
#define LLVM_SUPPORT_SIGNALS_H
|
2004-05-27 07:30:18 +02:00
|
|
|
|
2015-03-23 19:07:13 +01:00
|
|
|
#include <string>
|
2004-05-27 07:30:18 +02:00
|
|
|
|
|
|
|
namespace llvm {
|
2015-03-23 19:07:13 +01:00
|
|
|
class StringRef;
|
|
|
|
class raw_ostream;
|
2015-03-05 20:10:52 +01:00
|
|
|
|
2004-08-29 21:19:07 +02:00
|
|
|
namespace sys {
|
2004-05-27 07:30:18 +02:00
|
|
|
|
2010-05-08 04:10:34 +02:00
|
|
|
/// This function runs all the registered interrupt handlers, including the
|
|
|
|
/// removal of files registered by RemoveFileOnSignal.
|
|
|
|
void RunInterruptHandlers();
|
|
|
|
|
2005-04-21 22:48:15 +02:00
|
|
|
/// This function registers signal handlers to ensure that if a signal gets
|
2004-08-29 07:27:15 +02:00
|
|
|
/// delivered that the named file is removed.
|
|
|
|
/// @brief Remove a file if a fatal signal occurs.
|
2014-04-07 06:17:22 +02:00
|
|
|
bool RemoveFileOnSignal(StringRef Filename, std::string* ErrMsg = nullptr);
|
2013-06-13 23:01:17 +02:00
|
|
|
|
2010-09-01 16:17:34 +02:00
|
|
|
/// This function removes a file from the list of files to be removed on
|
|
|
|
/// signal delivery.
|
2013-06-13 23:16:58 +02:00
|
|
|
void DontRemoveFileOnSignal(StringRef Filename);
|
2010-09-01 16:17:34 +02:00
|
|
|
|
2005-04-21 22:48:15 +02:00
|
|
|
/// When an error signal (such as SIBABRT or SIGSEGV) is delivered to the
|
2004-08-29 07:27:15 +02:00
|
|
|
/// process, print a stack trace and then exit.
|
|
|
|
/// @brief Print a stack trace if a fatal signal occurs.
|
2015-04-07 22:43:23 +02:00
|
|
|
void PrintStackTraceOnErrorSignal(bool DisableCrashReporting = false);
|
2004-08-29 07:27:15 +02:00
|
|
|
|
2015-01-29 18:20:29 +01:00
|
|
|
/// Disable all system dialog boxes that appear when the process crashes.
|
|
|
|
void DisableSystemDialogsOnCrash();
|
|
|
|
|
2015-03-05 20:10:52 +01:00
|
|
|
/// \brief Print the stack trace using the given \c raw_ostream object.
|
|
|
|
void PrintStackTrace(raw_ostream &OS);
|
2013-01-09 20:42:40 +01:00
|
|
|
|
2009-03-04 22:21:36 +01:00
|
|
|
/// AddSignalHandler - Add a function to be called when an abort/kill signal
|
|
|
|
/// is delivered to the process. The handler can have a cookie passed to it
|
|
|
|
/// to identify what instance of the handler it is.
|
|
|
|
void AddSignalHandler(void (*FnPtr)(void *), void *Cookie);
|
|
|
|
|
2005-08-02 04:13:42 +02:00
|
|
|
/// This function registers a function to be called when the user "interrupts"
|
|
|
|
/// the program (typically by pressing ctrl-c). When the user interrupts the
|
|
|
|
/// program, the specified interrupt function is called instead of the program
|
|
|
|
/// being killed, and the interrupt function automatically disabled. Note
|
|
|
|
/// that interrupt functions are not allowed to call any non-reentrant
|
|
|
|
/// functions. An null interrupt function pointer disables the current
|
2005-08-02 05:04:47 +02:00
|
|
|
/// installed function. Note also that the handler may be executed on a
|
|
|
|
/// different thread on some platforms.
|
2005-08-02 04:13:42 +02:00
|
|
|
/// @brief Register a function to be called when ctrl-c is pressed.
|
|
|
|
void SetInterruptFunction(void (*IF)());
|
2004-08-29 21:19:07 +02:00
|
|
|
} // End sys namespace
|
2004-05-27 07:30:18 +02:00
|
|
|
} // End llvm namespace
|
|
|
|
|
|
|
|
#endif
|