[Lldb-commits] [PATCH] D18287: Don't try to redefine the signal() function on Windows
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Fri Mar 18 15:53:18 PDT 2016
zturner created this revision.
zturner added reviewers: amccarth, cameron314.
zturner added a subscriber: lldb-commits.
Windows comes with an extremely limited implementation of `signal` which only supports a few signal values. Of importance to LLDB is the `SIGINT` value which invokes a callback when the user presses Ctrl+C. For some reason, we were completely redefining the `signal()` function to intercept `SIGINT` and use our own custom processing of Ctrl+C rather than use the builtin processing of Ctrl+C done by `signal()`. This is frought with peril for a number of reasons:
1) Depending on order of includes, you could get into a situation where both builtin `signal()` and our own custom `signal()` are defined, leading to multiply defined symbol errors at link time.
2) It leads to a bunch of compiler warnings, since we end up redefining the same constants (e.g. `SIG_DFL` etc) because we were going through hoops to avoid #including the standard headers (even though that doesn't work)
3) The standard implementation of `signal()` actually does exactly what you would expect it to do with regards to Ctrl+C. In fact, by looking at the source code of the CRT, you can see that for `SIGINT` it actually just calls `SetConsoleCtrlHandler`, which is exactly what our own custom implementation of signal did!
So, we simply remove all of our custom windows versions of `signal()` and use the builtin implementation. Code that attempts to call `signal()` with values that are not supported on Windows are handled by preprocessor defines
http://reviews.llvm.org/D18287
Files:
tools/driver/Driver.cpp
tools/driver/Platform.cpp
tools/driver/Platform.h
tools/lldb-mi/CMakeLists.txt
tools/lldb-mi/Platform.cpp
tools/lldb-mi/Platform.h
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18287.51082.patch
Type: text/x-patch
Size: 5550 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160318/97b85184/attachment-0001.bin>
More information about the lldb-commits
mailing list