tracepoints: gnu-zero-variadic-macro-arguments warnings #26916

issue fanquake openend this issue on January 19, 2023
  1. fanquake commented at 9:35 am on January 19, 2023: member

    These occur for all tracepoints when using Clang 15 and a system installed systemtap:

     0# clang --version
     1Debian clang version 15.0.7
     2
     3./autogen.sh
     4./configure CC=clang-15 CXX=clang++-15
     5make
     6...
     7net_processing.cpp:4892:5: warning: must specify at least one argument for '...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments]
     8    TRACE6(net, inbound_message,
     9    ^
    10./util/trace.h:18:50: note: expanded from macro 'TRACE6'
    11#define TRACE6(context, event, a, b, c, d, e, f) DTRACE_PROBE6(context, event, a, b, c, d, e, f)
    12                                                 ^
    13/usr/include/aarch64-linux-gnu/sys/sdt.h:494:3: note: expanded from macro 'DTRACE_PROBE6'
    14  STAP_PROBE6(provider,probe,parm1,parm2,parm3,parm4,parm5,parm6)
    15  ^
    16/usr/include/aarch64-linux-gnu/sys/sdt.h:380:3: note: expanded from macro 'STAP_PROBE6'
    17  _SDT_PROBE(provider, name, 6, (arg1, arg2, arg3, arg4, arg5, arg6))
    18  ^
    19/usr/include/aarch64-linux-gnu/sys/sdt.h:78:75: note: expanded from macro '_SDT_PROBE'
    20    __asm__ __volatile__ (_SDT_ASM_BODY(provider, name, _SDT_ASM_ARGS, (n)) \
    21                                                                          ^
    22/usr/include/aarch64-linux-gnu/sys/sdt.h:283:9: note: macro '_SDT_ASM_BODY' defined here
    23#define _SDT_ASM_BODY(provider, name, pack_args, args, ...)                   \
    24        ^
    251 warning generated.
    
  2. hebasto commented at 10:59 am on January 23, 2023: member
    FWIW, on Ubuntu Lunar with systemtap-sdt-dev-4.8 being installed, warnings are gone when configuring with --enable-c++20.
  3. maflcko added the label Utils/log/libs on Jan 23, 2023
  4. 0xB10C commented at 12:04 pm on January 23, 2023: contributor

    FWIW, on Ubuntu Lunar with systemtap-sdt-dev-4.8 being installed, warnings are gone when configuring with --enable-c++20.

    fwiw I don’t think systemtap 4.8 is the reason there are no warnings for you. The changes form 4.7 to 4.8 in includes/sys/sdt.h file are minimal and shouldn’t affect this.

  5. hebasto commented at 12:09 pm on January 23, 2023: member

    FWIW, on Ubuntu Lunar with systemtap-sdt-dev-4.8 being installed, warnings are gone when configuring with --enable-c++20.

    fwiw I don’t think systemtap 4.8 is the reason there are no warnings for you. The changes form 4.7 to 4.8 in includes/sys/sdt.h file are minimal and shouldn’t affect this.

    Correct, the reason is --enable-c++20. See https://en.cppreference.com/w/cpp/preprocessor/replace.

  6. fanquake closed this on Jan 26, 2023

  7. fanquake reopened this on Jan 26, 2023

  8. fanquake commented at 1:46 pm on January 26, 2023: member
    Updated op to note that this is now system-installed systemtap only.
  9. sidhujag referenced this in commit 53564628e1 on Jan 26, 2023
  10. willcl-ark commented at 11:08 am on March 23, 2023: member

    This is still present with #26593 as it also uses an underlying variadic macro with 0 arguments via _SDT_ASM_BODY -> _SDT_PROBE -> _SDT_PROBE_N -> STAP_PROBEV -> TRACEPOINT.

    I tried to directly call the STAP_PROBE1 macro for the single argument case (on top of #26593), which would mean that all our remaining TRACEPOINT macros were invoked with >= 1 argument:

    0// A USDT tracepoint with one argument.
    1#define TRACEPOINT1(context, event) \
    2    if (TRACEPOINT_ACTIVE(context, event)) \
    3        STAP_PROBE1(context, event, arg)
    

    …but this apparently does not stop the warning, even though we are now never using an empty variadic argument:

     0wallet/spend.cpp:954:5: warning: must specify at least one argument for '...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments]
     1    TRACEPOINT(coin_selection, selected_coins, wallet.GetName().c_str(), GetAlgorithmName(result.GetAlgo()).c_str(), result.GetTarget(), result.GetWaste(), result.GetSelectedValue());
     2    ^
     3./util/trace.h:48:9: note: expanded from macro 'TRACEPOINT'
     4        STAP_PROBEV(context, event, __VA_ARGS__)
     5        ^
     6/usr/include/x86_64-linux-gnu/sys/sdt.h:422:3: note: expanded from macro 'STAP_PROBEV'
     7  _SDT_PROBE_N(provider, name, _SDT_NARG(0, ##__VA_ARGS__), ##__VA_ARGS__)
     8  ^
     9/usr/include/x86_64-linux-gnu/sys/sdt.h:420:3: note: expanded from macro '_SDT_PROBE_N'
    10  _SDT_PROBE(provider, name, N, (__VA_ARGS__))
    11  ^
    12/usr/include/x86_64-linux-gnu/sys/sdt.h:78:75: note: expanded from macro '_SDT_PROBE'
    13    __asm__ __volatile__ (_SDT_ASM_BODY(provider, name, _SDT_ASM_ARGS, (n)) \
    14                                                                          ^
    15/usr/include/x86_64-linux-gnu/sys/sdt.h:289:9: note: macro '_SDT_ASM_BODY' defined here
    16#define _SDT_ASM_BODY(provider, name, pack_args, args, ...)                   \
    17        ^
    

    It seems we have a few options therefore:

    1. Do nothing and wait until we move to c++20 (no timeline)
    2. Exclude the warning with global compile flags: CXXFLAGS += -Wno-gnu-zero-variadic-macro-arguments
    3. Add pragmas inside the macros to disable the warnings (diff based on #26593):
     0diff --git a/src/util/trace.h b/src/util/trace.h
     1index 816d8c295..e3fc0d8f4 100644
     2--- a/src/util/trace.h
     3+++ b/src/util/trace.h
     4@@ -32,15 +32,29 @@
     5 #define TRACEPOINT_ACTIVE(context, event) context##_##event##_semaphore > 0
     6 
     7 // A USDT tracepoint with no arguments.
     8+// Remove pragmas when we switch to c++20
     9 #define TRACEPOINT0(context, event) \
    10-    if (TRACEPOINT_ACTIVE(context, event)) \
    11-        STAP_PROBE(context, event)
    12+    do { \
    13+        _Pragma("clang diagnostic push") \
    14+        _Pragma("clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"") \
    15+        if (TRACEPOINT_ACTIVE(context, event)) { \
    16+            STAP_PROBE(context, event); \
    17+        } \
    18+        _Pragma("clang diagnostic pop") \
    19+    } while(0)
    20 
    21 // A USDT tracepoint with one to twelve arguments. It's checked that the
    22 // tracepoint is active before preparing its arguments.
    23+// Remove pragmas when we switch to c++20
    24 #define TRACEPOINT(context, event, ...) \
    25-    if (TRACEPOINT_ACTIVE(context, event)) \
    26-        STAP_PROBEV(context, event, __VA_ARGS__)
    27+    do { \
    28+        _Pragma("clang diagnostic push") \
    29+        _Pragma("clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"") \
    30+        if (TRACEPOINT_ACTIVE(context, event)) { \
    31+            STAP_PROBEV(context, event, __VA_ARGS__); \
    32+        } \
    33+        _Pragma("clang diagnostic pop") \
    34+    } while(0)
    35 
    36 #else
    
  11. martinus referenced this in commit 240e513e26 on Apr 3, 2023
  12. martinus referenced this in commit 5197660e94 on Apr 4, 2023
  13. fanquake referenced this in commit 1e9376f265 on Jun 17, 2023
  14. fanquake referenced this in commit d357cb0ec4 on Jun 17, 2023
  15. fanquake referenced this in commit 2618b4e44a on Jun 28, 2023
  16. fanquake referenced this in commit 5ec4cce500 on Jul 27, 2023
  17. fanquake referenced this in commit 0485a5948f on Aug 3, 2023
  18. fanquake referenced this in commit 97ba72117c on Aug 7, 2023
  19. fanquake closed this on Aug 7, 2023

  20. brunoerg referenced this in commit d012cba14a on Aug 7, 2023
  21. sidhujag referenced this in commit 36f919d626 on Aug 9, 2023
  22. Retropex referenced this in commit 47dfa60aea on Oct 4, 2023
  23. Retropex referenced this in commit 5f62ed90f6 on Oct 4, 2023
  24. bitcoin locked this on Aug 6, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-21 09:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me