[lldb] Add compile time checks for signal codes when on the matching platform
authorDavid Spickett <david.spickett@linaro.org>
Thu, 16 Mar 2023 11:32:35 +0000 (11:32 +0000)
committerDavid Spickett <david.spickett@linaro.org>
Tue, 21 Mar 2023 11:45:13 +0000 (11:45 +0000)
commitc8af0d3cea8cab9277651f8cabe54e2f1a3b167f
tree807f28bac320f0ecdd2ecb0c00ee008e101285d2
parentaf99aa0ff77da893457605113062220957dc7499
[lldb] Add compile time checks for signal codes when on the matching platform

This adds a new macro to the UnixSignals subclasses, ADD_SIGCODE.

ADD_SIGCODE(4, ILL_ILLOPC, 1, "illegal opcode");

Adds a sigcode to signal 4. That code is ILL_ILLOPC and we expect
its value to be 1. When compiling on a system that matches the class
e.g. FreeBSD for FreeBSDSignals, the macro will check that that is true.

When you're not on FreeBSD we just use the number 1, and ILL_ILLOPC
won't be defined to anything because we don't include csignal.

Example error:
LinuxSignals.cpp:52:3: error: static_assert failed due to requirement
'ILL_COPROC == 9' "Value mismatch for signal code ILL_COPROC"

Reviewed By: arichardson

Differential Revision: https://reviews.llvm.org/D146222
lldb/include/lldb/Target/UnixSignals.h
lldb/source/Plugins/Platform/FreeBSD/FreeBSDSignals.cpp
lldb/source/Plugins/Platform/Linux/LinuxSignals.cpp
lldb/source/Plugins/Platform/NetBSD/NetBSDSignals.cpp