systemtap - Systemtap (stap) 探测失败并显示“此语句可能会通过 [-Werror=implicit-fallthrough=]”
问题描述
从 5.2 到 5.3.5 的内核更新后,我的 SystemTAP(stap)探测失败,并出现以下错误
/usr/share/systemtap/runtime/map-gen.c: In function ‘hash_si’:
/usr/share/systemtap/runtime/map-gen.c:114:28: error: this statement may fall through [-Werror=implicit-fallthrough=]
114 | case 3: k1 ^= tail[2] << 16; \
| ~~~^~~~~~~~~~~~~~~~
/usr/share/systemtap/runtime/map-gen.c:131:19: note: in expansion of macro ‘MURMUR_STRING’
131 | #define KEY1_HASH MURMUR_STRING(key1)
| ^~~~~~~~~~~~~
/usr/share/systemtap/runtime/map-gen.c:664:9: note: in expansion of macro ‘KEY1_HASH’
664 | KEY1_HASH;
| ^~~~~~~~~
/usr/share/systemtap/runtime/map-gen.c:115:17: note: here
115 | case 2: k1 ^= tail[1] << 8; \
| ^~~~
为什么?
解决方案
目前尚不清楚为什么会在内核更新后发生这种情况,因为它似乎更常见的是 gcc/工具链更改。它看起来与先前的问题相关/相似:
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=853676
- https://sourceware.org/git/?p=systemtap.git;a=commit;h=575fe913f6b6b81421f7bfda7c72ab8c15ecb8e3
在任何情况下,都可以通过对 systemtap 运行时代码的小修改来在本地解决它以禁用警告。在文件中:
/usr/share/systemtap/runtime/vsprintf.c
/usr/share/systemtap/runtime/map-gen.c
在每个文件的开头插入以下两行
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
和文件末尾的这一行:
#pragma GCC diagnostic pop
编辑:为 systemtap发布错误https://sourceware.org/bugzilla/show_bug.cgi?id=25267
编辑:如果您不介意重新编译 systemtap,一个更干净的修复方法是修改runtime.cxx
如下:
diff --git a/buildrun.cxx b/buildrun.cxx
index 505902bc5..b29eeb797 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -235,6 +235,7 @@ compile_dyninst (systemtap_session& s)
"gcc", "--std=gnu99", s.translated_source, "-o", module,
"-fvisibility=hidden", "-O2", "-I" + s.runtime_path, "-D__DYNINST__",
"-Wall", WERROR, "-Wno-unused", "-Wno-strict-aliasing",
+ "-Wno-error=implicit-fallthrough", "-Wno-error=strict-prototypes",
"-pthread", "-lrt", "-fPIC", "-shared",
};
然后重新编译并重新安装。这可以解决这两个 systemtap 错误:
推荐阅读
- php - 类型提示如何与 Closure::call 一起使用?
- c# - 从 C# 程序接收 xml 字符串无法在 Python 3.5 中使用 ET.fromstring 进行解析
- python - 如何在kivy中刺激按钮?
- c++ - UMDF 驱动程序是否可以写入文件?
- algorithm - 是 2^n = Ω(2^(n + k)) 对于某个常数 k?
- tensorflow - 将训练图转换为推理图?(删除 TF 中的批量标准化)
- javascript - javascript ImageData 复制或移动性能
- c# - ASP NET Http 模块在异常之前没有收到大请求
- android - 找不到“android.permission.INTERNET”权限到应该使用它的著名方法的映射
- spring-boot - 如何在 Spring Boot 中正确配置 ldap 身份验证?每次我登录时,它都会在调用 /auth 后重定向到 /login