[Lldb-commits] [PATCH] D37926: Fix the SIGINT handlers
This revision was automatically updated to reflect the committed changes. Closed by commit rL313785: Fix the SIGINT handlers (authored by amccarth). Changed prior to commit: https://reviews.llvm.org/D37926?vs=115473=116035#toc Repository: rL LLVM https://reviews.llvm.org/D37926 Files: lldb/trunk/tools/driver/Driver.cpp lldb/trunk/tools/lldb-mi/MIDriverMain.cpp Index: lldb/trunk/tools/driver/Driver.cpp === --- lldb/trunk/tools/driver/Driver.cpp +++ lldb/trunk/tools/driver/Driver.cpp @@ -9,6 +9,7 @@ #include "Driver.h" +#include #include #include #include @@ -1177,17 +1178,16 @@ } void sigint_handler(int signo) { - static bool g_interrupt_sent = false; + static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT; if (g_driver) { -if (!g_interrupt_sent) { - g_interrupt_sent = true; +if (!g_interrupt_sent.test_and_set()) { g_driver->GetDebugger().DispatchInputInterrupt(); - g_interrupt_sent = false; + g_interrupt_sent.clear(); return; } } - exit(signo); + _exit(signo); } void sigtstp_handler(int signo) { Index: lldb/trunk/tools/lldb-mi/MIDriverMain.cpp === --- lldb/trunk/tools/lldb-mi/MIDriverMain.cpp +++ lldb/trunk/tools/lldb-mi/MIDriverMain.cpp @@ -33,6 +33,7 @@ // Third party headers: #include "lldb/API/SBHostOS.h" +#include #include #include @@ -72,14 +73,13 @@ #ifdef _WIN32 // Restore handler as it is not persistent on Windows signal(SIGINT, sigint_handler); #endif - static bool g_interrupt_sent = false; + static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT; CMIDriverMgr = CMIDriverMgr::Instance(); lldb::SBDebugger *pDebugger = rDriverMgr.DriverGetTheDebugger(); if (pDebugger != nullptr) { -if (!g_interrupt_sent) { - g_interrupt_sent = true; +if (!g_interrupt_sent.test_and_set()) { pDebugger->DispatchInputInterrupt(); - g_interrupt_sent = false; + g_interrupt_sent.clear(); } } Index: lldb/trunk/tools/driver/Driver.cpp === --- lldb/trunk/tools/driver/Driver.cpp +++ lldb/trunk/tools/driver/Driver.cpp @@ -9,6 +9,7 @@ #include "Driver.h" +#include #include #include #include @@ -1177,17 +1178,16 @@ } void sigint_handler(int signo) { - static bool g_interrupt_sent = false; + static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT; if (g_driver) { -if (!g_interrupt_sent) { - g_interrupt_sent = true; +if (!g_interrupt_sent.test_and_set()) { g_driver->GetDebugger().DispatchInputInterrupt(); - g_interrupt_sent = false; + g_interrupt_sent.clear(); return; } } - exit(signo); + _exit(signo); } void sigtstp_handler(int signo) { Index: lldb/trunk/tools/lldb-mi/MIDriverMain.cpp === --- lldb/trunk/tools/lldb-mi/MIDriverMain.cpp +++ lldb/trunk/tools/lldb-mi/MIDriverMain.cpp @@ -33,6 +33,7 @@ // Third party headers: #include "lldb/API/SBHostOS.h" +#include #include #include @@ -72,14 +73,13 @@ #ifdef _WIN32 // Restore handler as it is not persistent on Windows signal(SIGINT, sigint_handler); #endif - static bool g_interrupt_sent = false; + static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT; CMIDriverMgr = CMIDriverMgr::Instance(); lldb::SBDebugger *pDebugger = rDriverMgr.DriverGetTheDebugger(); if (pDebugger != nullptr) { -if (!g_interrupt_sent) { - g_interrupt_sent = true; +if (!g_interrupt_sent.test_and_set()) { pDebugger->DispatchInputInterrupt(); - g_interrupt_sent = false; + g_interrupt_sent.clear(); } } ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D37926: Fix the SIGINT handlers
clayborg added a comment. Looks fine to me. https://reviews.llvm.org/D37926 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D37926: Fix the SIGINT handlers
zturner added a comment. It turns out the function this called, `DispatchInputInterrupt`, already acquires a mutex. Maybe put the synchronization in there? Then you don't have to reproduce the synchronization in both MI and LLDB https://reviews.llvm.org/D37926 ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D37926: Fix the SIGINT handlers
lemo created this revision. Herald added a subscriber: ki.stfu. 1. Fix a data race (g_interrupt_sent flag usage was not thread safe, signals can be handled on arbitrary threads) 2. exit() is not signal-safe, replaced it with the signal-safe equivalent _exit() https://reviews.llvm.org/D37926 Files: driver/Driver.cpp lldb-mi/MIDriverMain.cpp Index: lldb-mi/MIDriverMain.cpp === --- lldb-mi/MIDriverMain.cpp +++ lldb-mi/MIDriverMain.cpp @@ -72,14 +72,13 @@ #ifdef _WIN32 // Restore handler as it is not persistent on Windows signal(SIGINT, sigint_handler); #endif - static bool g_interrupt_sent = false; + static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT; CMIDriverMgr = CMIDriverMgr::Instance(); lldb::SBDebugger *pDebugger = rDriverMgr.DriverGetTheDebugger(); if (pDebugger != nullptr) { -if (!g_interrupt_sent) { - g_interrupt_sent = true; +if (!g_interrupt_sent.test_and_set()) { pDebugger->DispatchInputInterrupt(); - g_interrupt_sent = false; + g_interrupt_sent.clear(); } } Index: driver/Driver.cpp === --- driver/Driver.cpp +++ driver/Driver.cpp @@ -1177,17 +1177,16 @@ } void sigint_handler(int signo) { - static bool g_interrupt_sent = false; + static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT; if (g_driver) { -if (!g_interrupt_sent) { - g_interrupt_sent = true; +if (!g_interrupt_sent.test_and_set()) { g_driver->GetDebugger().DispatchInputInterrupt(); - g_interrupt_sent = false; + g_interrupt_sent.clear(); return; } } - exit(signo); + _exit(signo); } void sigtstp_handler(int signo) { Index: lldb-mi/MIDriverMain.cpp === --- lldb-mi/MIDriverMain.cpp +++ lldb-mi/MIDriverMain.cpp @@ -72,14 +72,13 @@ #ifdef _WIN32 // Restore handler as it is not persistent on Windows signal(SIGINT, sigint_handler); #endif - static bool g_interrupt_sent = false; + static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT; CMIDriverMgr = CMIDriverMgr::Instance(); lldb::SBDebugger *pDebugger = rDriverMgr.DriverGetTheDebugger(); if (pDebugger != nullptr) { -if (!g_interrupt_sent) { - g_interrupt_sent = true; +if (!g_interrupt_sent.test_and_set()) { pDebugger->DispatchInputInterrupt(); - g_interrupt_sent = false; + g_interrupt_sent.clear(); } } Index: driver/Driver.cpp === --- driver/Driver.cpp +++ driver/Driver.cpp @@ -1177,17 +1177,16 @@ } void sigint_handler(int signo) { - static bool g_interrupt_sent = false; + static std::atomic_flag g_interrupt_sent = ATOMIC_FLAG_INIT; if (g_driver) { -if (!g_interrupt_sent) { - g_interrupt_sent = true; +if (!g_interrupt_sent.test_and_set()) { g_driver->GetDebugger().DispatchInputInterrupt(); - g_interrupt_sent = false; + g_interrupt_sent.clear(); return; } } - exit(signo); + _exit(signo); } void sigtstp_handler(int signo) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits