2010-11-29 19:44:50 +00:00
|
|
|
//===- llvm/Support/Signals.h - Signal Handling support ----------*- C++ -*-===//
|
2005-04-21 20:48:15 +00:00
|
|
|
//
|
2003-10-20 19:46:57 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 20:48:15 +00:00
|
|
|
//
|
2003-10-20 19:46:57 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-04-18 19:53:34 +00:00
|
|
|
//
|
|
|
|
// This file defines some helpful functions for dealing with the possibility of
|
2011-04-15 05:18:47 +00:00
|
|
|
// unix signals occurring while your program is running.
|
2002-04-18 19:53:34 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2013-01-10 00:45:19 +00:00
|
|
|
#ifndef LLVM_SUPPORT_SIGNALS_H
|
|
|
|
#define LLVM_SUPPORT_SIGNALS_H
|
2002-04-18 19:53:34 +00:00
|
|
|
|
2010-11-29 18:16:10 +00:00
|
|
|
#include "llvm/Support/Path.h"
|
2013-01-10 05:23:59 +00:00
|
|
|
#include <cstdio>
|
2002-04-18 19:53:34 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
2004-08-29 19:19:07 +00:00
|
|
|
namespace sys {
|
2003-11-11 22:41:34 +00:00
|
|
|
|
2010-05-08 02:10:34 +00:00
|
|
|
/// This function runs all the registered interrupt handlers, including the
|
|
|
|
/// removal of files registered by RemoveFileOnSignal.
|
|
|
|
void RunInterruptHandlers();
|
|
|
|
|
2005-04-21 20:48:15 +00:00
|
|
|
/// This function registers signal handlers to ensure that if a signal gets
|
2004-08-29 05:27:15 +00:00
|
|
|
/// delivered that the named file is removed.
|
|
|
|
/// @brief Remove a file if a fatal signal occurs.
|
2014-04-07 04:17:22 +00:00
|
|
|
bool RemoveFileOnSignal(StringRef Filename, std::string* ErrMsg = nullptr);
|
2013-06-13 21:01:17 +00:00
|
|
|
|
2010-09-01 14:17:34 +00:00
|
|
|
/// This function removes a file from the list of files to be removed on
|
|
|
|
/// signal delivery.
|
2013-06-13 21:16:58 +00:00
|
|
|
void DontRemoveFileOnSignal(StringRef Filename);
|
2010-09-01 14:17:34 +00:00
|
|
|
|
2005-04-21 20:48:15 +00:00
|
|
|
/// When an error signal (such as SIBABRT or SIGSEGV) is delivered to the
|
2004-08-29 05:27:15 +00:00
|
|
|
/// process, print a stack trace and then exit.
|
|
|
|
/// @brief Print a stack trace if a fatal signal occurs.
|
2004-02-19 20:03:08 +00:00
|
|
|
void PrintStackTraceOnErrorSignal();
|
2004-08-29 05:27:15 +00:00
|
|
|
|
2013-01-09 19:42:40 +00:00
|
|
|
/// \brief Print the stack trace using the given \c FILE object.
|
|
|
|
void PrintStackTrace(FILE *);
|
|
|
|
|
2009-03-04 21:21:36 +00: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 02:13:42 +00: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 03:04:47 +00:00
|
|
|
/// installed function. Note also that the handler may be executed on a
|
|
|
|
/// different thread on some platforms.
|
2005-08-02 02:13:42 +00:00
|
|
|
/// @brief Register a function to be called when ctrl-c is pressed.
|
|
|
|
void SetInterruptFunction(void (*IF)());
|
2004-08-29 19:19:07 +00:00
|
|
|
} // End sys namespace
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
2002-12-12 03:43:30 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
#endif
|