[Lldb-commits] [lldb] r227964 - Restore the signal handler for Windows as it is not presistent there.

Abid, Hafiz Hafiz_Abid at mentor.com
Tue Feb 3 05:21:33 PST 2015


Just figured that for MSVC, lldb-mi is using its own implementation of signal which
calls SetConsoleCtrlHandler () internally and works without restoring signal handler.
The handler needs to be restored for stock signal implementation though.  Also new
code not seem to cause any problem for MSVC so I am leaving it in for now.

If someone sees a problem with it then I can rework it.

Thanks,
Abid
 

> -----Original Message-----
> From: lldb-commits-bounces at cs.uiuc.edu [mailto:lldb-commits-
> bounces at cs.uiuc.edu] On Behalf Of Abid, Hafiz
> Sent: 03 February 2015 11:20
> To: lldb-commits at cs.uiuc.edu
> Subject: [Lldb-commits] [lldb] r227964 - Restore the signal handler for
> Windows as it is not presistent there.
> 
> Author: abidh
> Date: Tue Feb  3 05:20:00 2015
> New Revision: 227964
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=227964&view=rev
> Log:
> Restore the signal handler for Windows as it is not presistent there.
> 
> On windows, signal handler is reset to default once a signal is received.
> This causes doing ctrl-c twice on console (or pressing suspend button twice
> in eclipse ide which uses SIGINT to stop the debuggee) to crash lldb-mi on
> windows. Although there is very tiny window (after signal handler is called
> and before we restore the handler) where default handler will be in place.
> But this is hardly a problem in practice as IDEs generally disable their
> suspend button once it has been presses.
> 
> 
> 
> Modified:
>     lldb/trunk/tools/lldb-mi/MIDriverMain.cpp
> 
> Modified: lldb/trunk/tools/lldb-mi/MIDriverMain.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-
> mi/MIDriverMain.cpp?rev=227964&r1=227963&r2=227964&view=diff
> ================================================================
> ==============
> --- lldb/trunk/tools/lldb-mi/MIDriverMain.cpp (original)
> +++ lldb/trunk/tools/lldb-mi/MIDriverMain.cpp Tue Feb  3 05:20:00 2015
> @@ -81,6 +81,9 @@
>  void
>  sigwinch_handler(int vSigno)
>  {
> +#ifdef _WIN32 // Restore handler as it is not persistent on Windows
> +    signal(SIGWINCH, sigwinch_handler);
> +#endif
>      MIunused(vSigno);
> 
>      struct winsize window_size;
> @@ -111,6 +114,9 @@ sigwinch_handler(int vSigno)
>  void
>  sigint_handler(int vSigno)
>  {
> +#ifdef _WIN32 // Restore handler as it is not persistent on Windows
> +    signal(SIGINT, sigint_handler);
> +#endif
>      static bool g_interrupt_sent = false;
>      CMIDriverMgr &rDriverMgr = CMIDriverMgr::Instance();
>      lldb::SBDebugger *pDebugger = rDriverMgr.DriverGetTheDebugger();
> @@ -147,6 +153,9 @@ sigint_handler(int vSigno)
>  void
>  sigtstp_handler(int vSigno)
>  {
> +#ifdef _WIN32 // Restore handler as it is not persistent on Windows
> +    signal(SIGTSTP, sigtstp_handler);
> +#endif
>      CMIDriverMgr &rDriverMgr = CMIDriverMgr::Instance();
>      lldb::SBDebugger *pDebugger = rDriverMgr.DriverGetTheDebugger();
>      if (pDebugger != nullptr)
> @@ -175,6 +184,9 @@ sigtstp_handler(int vSigno)
>  void
>  sigcont_handler(int vSigno)
>  {
> +#ifdef _WIN32 // Restore handler as it is not persistent on Windows
> +    signal(SIGCONT, sigcont_handler);
> +#endif
>      CMIDriverMgr &rDriverMgr = CMIDriverMgr::Instance();
>      lldb::SBDebugger *pDebugger = rDriverMgr.DriverGetTheDebugger();
>      if (pDebugger != nullptr)
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits




More information about the lldb-commits mailing list