Rename RunCallBacksToRun to llvm::sys::RunSignalHandlers
authorYaron Keren <yaron.keren@gmail.com>
Wed, 22 Jul 2015 21:11:17 +0000 (21:11 +0000)
committerYaron Keren <yaron.keren@gmail.com>
Wed, 22 Jul 2015 21:11:17 +0000 (21:11 +0000)
And expose it in Signals.h, allowing clients to call it directly,
possibly LLVMErrorHandler which currently calls RunInterruptHandlers
but not RunSignalHandlers, thus for example not printing the stack
backtrace on Unixish OSes. On Windows it does happen because
RunInterruptHandlers ends up calling the callbacks as well via
Cleanup(). This difference in behaviour and code structures in
*/Signals.inc should be patched in the future.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242936 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/Signals.h
lib/Support/Signals.cpp
lib/Support/Unix/Signals.inc
lib/Support/Windows/Signals.inc

index 7e165d7f3a4287bac093cfb0c4964288ae24a64b..2a4d84bd891a12f8dc1f85cf68e7dc74b4ebff7a 100644 (file)
@@ -47,6 +47,9 @@ namespace sys {
   /// \brief Print the stack trace using the given \c raw_ostream object.
   void PrintStackTrace(raw_ostream &OS);
 
+  // Run all registered signal handlers.
+  void RunSignalHandlers();
+
   /// 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.
index 598ef50175aa22033f21242531d64da490069058..2c3560c3be90619c3642366c3a3079504c1936df 100644 (file)
@@ -28,7 +28,7 @@ using namespace sys;
 
 static ManagedStatic<std::vector<std::pair<void (*)(void *), void *>>>
     CallBacksToRun;
-void RunCallBacksToRun() {
+void sys::RunSignalHandlers() {
   if (!CallBacksToRun.isConstructed())
     return;
   for (auto &I : *CallBacksToRun)
index caccf7b377c9315453f4bd316d49a304fa82597a..2332db58bfc96a41d2e4e86c836a9100e345ceed 100644 (file)
@@ -201,7 +201,7 @@ static RETSIGTYPE SignalHandler(int Sig) {
   }
 
   // Otherwise if it is a fault (like SEGV) run any handler.
-  RunCallBacksToRun();
+  llvm::sys::RunSignalHandlers();
 
 #ifdef __s390__
   // On S/390, certain signals are delivered with PSW Address pointing to
index c8bc646fd2c23b2b4948758ae437c204c8f9d643..824edb3c39b2836138b4d6e12bb6a0c1ab116d68 100644 (file)
@@ -457,7 +457,7 @@ static void Cleanup() {
       llvm::sys::fs::remove(FilesToRemove->back());
       FilesToRemove->pop_back();
     }
-  RunCallBacksToRun();
+  llvm::sys::RunSignalHandlers();
   LeaveCriticalSection(&CriticalSection);
 }