[all-commits] [llvm/llvm-project] c8af0d: [lldb] Add compile time checks for signal codes wh...

David Spickett via All-commits all-commits at lists.llvm.org
Tue Mar 21 04:45:28 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c8af0d3cea8cab9277651f8cabe54e2f1a3b167f
      https://github.com/llvm/llvm-project/commit/c8af0d3cea8cab9277651f8cabe54e2f1a3b167f
  Author: David Spickett <david.spickett at linaro.org>
  Date:   2023-03-21 (Tue, 21 Mar 2023)

  Changed paths:
    M lldb/include/lldb/Target/UnixSignals.h
    M lldb/source/Plugins/Platform/FreeBSD/FreeBSDSignals.cpp
    M lldb/source/Plugins/Platform/Linux/LinuxSignals.cpp
    M lldb/source/Plugins/Platform/NetBSD/NetBSDSignals.cpp

  Log Message:
  -----------
  [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




More information about the All-commits mailing list