Compare commits
3 Commits
ea59c07de8
...
5a16c8be50
Author | SHA1 | Date |
---|---|---|
Viktor Malik | 5a16c8be50 | |
Viktor Malik | 8f9b08b6e0 | |
Viktor Malik | bde7b370c7 |
|
@ -0,0 +1 @@
|
|||
b17c71c9c5a78cbe152b1346e6d18f29eb6e4b9e bpftrace-0.19.1.tar.gz
|
|
@ -13,3 +13,4 @@
|
|||
/bpftrace-0.16.0.tar.gz
|
||||
/cereal-1.3.2.tar.gz
|
||||
/bpftrace-0.17.0.tar.gz
|
||||
/bpftrace-0.19.1.tar.gz
|
||||
|
|
|
@ -1,160 +0,0 @@
|
|||
From 79d849a3a0462ab0a33cbf208e27e28d05eab213 Mon Sep 17 00:00:00 2001
|
||||
From: Viktor Malik <viktor.malik@gmail.com>
|
||||
Date: Fri, 3 Mar 2023 08:28:54 +0100
|
||||
Subject: [PATCH 1/2] Parse kernel configuration
|
||||
|
||||
In future, it may (and will) be useful to have access to the running
|
||||
kernel configuration, e.g. to add config-specific compilation options to
|
||||
ClangParser.
|
||||
|
||||
This adds and fills a new map BPFtrace::kconfig that maps config options
|
||||
to their values. Both the option name and the value are strings. The
|
||||
configuration is parsed from one of two sources:
|
||||
- /boot/config-$(uname -r)
|
||||
- /proc/config.gz
|
||||
|
||||
For testing purposes, the config filename may be passed through the
|
||||
BPFTRACE_KCONFIG_TEST env variable.
|
||||
---
|
||||
src/bpftrace.h | 1 +
|
||||
src/utils.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
src/utils.h | 12 ++++++++++++
|
||||
tests/utils.cpp | 19 +++++++++++++++++++
|
||||
4 files changed, 82 insertions(+)
|
||||
|
||||
diff --git a/src/bpftrace.h b/src/bpftrace.h
|
||||
index a6a8c00b..94587bff 100644
|
||||
--- a/src/bpftrace.h
|
||||
+++ b/src/bpftrace.h
|
||||
@@ -168,6 +168,7 @@ public:
|
||||
std::map<libbpf::bpf_func_id, location> helper_use_loc_;
|
||||
// mapping traceable functions to modules (or "vmlinux") that they appear in
|
||||
FuncsModulesMap traceable_funcs_;
|
||||
+ KConfig kconfig;
|
||||
std::vector<std::unique_ptr<AttachedProbe>> attached_probes_;
|
||||
|
||||
std::map<std::string, std::unique_ptr<PCAPwriter>> pcap_writers;
|
||||
diff --git a/src/utils.cpp b/src/utils.cpp
|
||||
index 2d9c6695..54c8f054 100644
|
||||
--- a/src/utils.cpp
|
||||
+++ b/src/utils.cpp
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <bcc/bcc_syms.h>
|
||||
#include <bcc/bcc_usdt.h>
|
||||
#include <elf.h>
|
||||
+#include <zlib.h>
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
@@ -178,6 +179,55 @@ StdioSilencer::~StdioSilencer()
|
||||
}
|
||||
}
|
||||
|
||||
+KConfig::KConfig()
|
||||
+{
|
||||
+ std::vector<std::string> config_locs;
|
||||
+
|
||||
+ // Try to get the config from BPFTRACE_KCONFIG_TEST env
|
||||
+ // If not set, use the set of default locations
|
||||
+ const char *path_env = std::getenv("BPFTRACE_KCONFIG_TEST");
|
||||
+ if (path_env)
|
||||
+ config_locs = { std::string(path_env) };
|
||||
+ else
|
||||
+ {
|
||||
+ struct utsname utsname;
|
||||
+ if (uname(&utsname) < 0)
|
||||
+ return;
|
||||
+ config_locs = {
|
||||
+ "/boot/config-" + std::string(utsname.release),
|
||||
+ "/proc/config.gz",
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+ for (auto &path : config_locs)
|
||||
+ {
|
||||
+ // gzopen/gzgets handle both uncompressed and compressed files
|
||||
+ gzFile file = gzopen(path.c_str(), "r");
|
||||
+ if (!file)
|
||||
+ continue;
|
||||
+
|
||||
+ char buf[4096];
|
||||
+ while (gzgets(file, buf, sizeof(buf)))
|
||||
+ {
|
||||
+ std::string option(buf);
|
||||
+ if (option.find("CONFIG_") == 0)
|
||||
+ {
|
||||
+ // trim trailing '\n'
|
||||
+ if (option[option.length() - 1] == '\n')
|
||||
+ option = option.substr(0, option.length() - 1);
|
||||
+
|
||||
+ auto split = option.find("=");
|
||||
+ if (split == std::string::npos)
|
||||
+ continue;
|
||||
+
|
||||
+ config.emplace(option.substr(0, split), option.substr(split + 1));
|
||||
+ }
|
||||
+ }
|
||||
+ gzclose(file);
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+
|
||||
bool get_uint64_env_var(const std::string &str, uint64_t &dest)
|
||||
{
|
||||
if (const char* env_p = std::getenv(str.c_str()))
|
||||
diff --git a/src/utils.h b/src/utils.h
|
||||
index dccc4504..a76aa161 100644
|
||||
--- a/src/utils.h
|
||||
+++ b/src/utils.h
|
||||
@@ -130,6 +130,18 @@ struct DeprecatedName
|
||||
typedef std::unordered_map<std::string, std::unordered_set<std::string>>
|
||||
FuncsModulesMap;
|
||||
|
||||
+struct KConfig
|
||||
+{
|
||||
+ KConfig();
|
||||
+ bool has_value(const std::string &name, const std::string &value) const
|
||||
+ {
|
||||
+ auto c = config.find(name);
|
||||
+ return c != config.end() && c->second == value;
|
||||
+ }
|
||||
+
|
||||
+ std::unordered_map<std::string, std::string> config;
|
||||
+};
|
||||
+
|
||||
static std::vector<DeprecatedName> DEPRECATED_LIST =
|
||||
{
|
||||
};
|
||||
diff --git a/tests/utils.cpp b/tests/utils.cpp
|
||||
index 9ca4ace5..8470745b 100644
|
||||
--- a/tests/utils.cpp
|
||||
+++ b/tests/utils.cpp
|
||||
@@ -222,6 +222,25 @@ TEST(utils, get_cgroup_path_in_hierarchy)
|
||||
}
|
||||
}
|
||||
|
||||
+TEST(utils, parse_kconfig)
|
||||
+{
|
||||
+ char path[] = "/tmp/configXXXXXX";
|
||||
+ int fd = mkstemp(path);
|
||||
+ const std::string config = "# Intro comment\n"
|
||||
+ "CONFIG_YES=y\n"
|
||||
+ "CONFIG_MOD=m\n"
|
||||
+ "CONFIG_VAL=42\n"
|
||||
+ "# CONFIG_NO is not set";
|
||||
+ EXPECT_EQ(write(fd, config.c_str(), config.length()), config.length());
|
||||
+ setenv("BPFTRACE_KCONFIG_TEST", path, true);
|
||||
+
|
||||
+ KConfig kconfig;
|
||||
+ ASSERT_TRUE(kconfig.has_value("CONFIG_YES", "y"));
|
||||
+ ASSERT_TRUE(kconfig.has_value("CONFIG_MOD", "m"));
|
||||
+ ASSERT_TRUE(kconfig.has_value("CONFIG_VAL", "42"));
|
||||
+ ASSERT_EQ(kconfig.config.find("CONFIG_NO"), kconfig.config.end());
|
||||
+}
|
||||
+
|
||||
} // namespace utils
|
||||
} // namespace test
|
||||
} // namespace bpftrace
|
||||
--
|
||||
2.39.2
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
From 29c5d381cd4d36b5e3ce140193729a5a4b97c31e Mon Sep 17 00:00:00 2001
|
||||
From: Viktor Malik <viktor.malik@gmail.com>
|
||||
Date: Mon, 6 Mar 2023 11:41:27 +0100
|
||||
Subject: [PATCH 2/2] arm64: define the KASAN_SHADOW_SCALE_SHIFT macro
|
||||
|
||||
arm64 defines this macro from Makefile instead of defining it in a
|
||||
header file as is the case for other architectures. Since we're not
|
||||
running make, we need to define the macro manually via CFLAGS.
|
||||
|
||||
The value definition is taken from kernel's arch/arm64/Makefile and it
|
||||
depends on the running kernel configuration.
|
||||
|
||||
This fixes the runqlat.bt tcpdrop.bt, and undump.bt tools on
|
||||
aarch64+debug kernel which previously failed with:
|
||||
|
||||
# /usr/share/bpftrace/tools/runqlat.bt
|
||||
[...]/source/arch/arm64/include/asm/memory.h:300:9: error: use of undeclared identifier 'KASAN_SHADOW_SCALE_SHIFT'
|
||||
[...]
|
||||
---
|
||||
src/main.cpp | 3 ++-
|
||||
src/utils.cpp | 23 ++++++++++++++++++-----
|
||||
src/utils.h | 3 ++-
|
||||
3 files changed, 22 insertions(+), 7 deletions(-)
|
||||
|
||||
diff --git a/src/main.cpp b/src/main.cpp
|
||||
index b76d1bb3..593c71be 100644
|
||||
--- a/src/main.cpp
|
||||
+++ b/src/main.cpp
|
||||
@@ -370,7 +370,8 @@ static std::optional<struct timespec> get_boottime()
|
||||
kobj = std::get<1>(kdirs);
|
||||
|
||||
if (ksrc != "")
|
||||
- extra_flags = get_kernel_cflags(utsname.machine, ksrc, kobj);
|
||||
+ extra_flags = get_kernel_cflags(
|
||||
+ utsname.machine, ksrc, kobj, bpftrace.kconfig);
|
||||
}
|
||||
extra_flags.push_back("-include");
|
||||
extra_flags.push_back(CLANG_WORKAROUNDS_H);
|
||||
diff --git a/src/utils.cpp b/src/utils.cpp
|
||||
index 54c8f054..c8fd7da1 100644
|
||||
--- a/src/utils.cpp
|
||||
+++ b/src/utils.cpp
|
||||
@@ -227,7 +227,6 @@ KConfig::KConfig()
|
||||
}
|
||||
}
|
||||
|
||||
-
|
||||
bool get_uint64_env_var(const std::string &str, uint64_t &dest)
|
||||
{
|
||||
if (const char* env_p = std::getenv(str.c_str()))
|
||||
@@ -364,10 +363,10 @@ std::vector<int> get_possible_cpus()
|
||||
return read_cpu_range("/sys/devices/system/cpu/possible");
|
||||
}
|
||||
|
||||
-std::vector<std::string> get_kernel_cflags(
|
||||
- const char* uname_machine,
|
||||
- const std::string& ksrc,
|
||||
- const std::string& kobj)
|
||||
+std::vector<std::string> get_kernel_cflags(const char *uname_machine,
|
||||
+ const std::string &ksrc,
|
||||
+ const std::string &kobj,
|
||||
+ const KConfig &kconfig)
|
||||
{
|
||||
std::vector<std::string> cflags;
|
||||
std::string arch = uname_machine;
|
||||
@@ -433,6 +432,20 @@ std::vector<std::string> get_kernel_cflags(
|
||||
cflags.push_back("-D__LINUX_ARM_ARCH__=7");
|
||||
}
|
||||
|
||||
+ if (arch == "arm64")
|
||||
+ {
|
||||
+ // arm64 defines KASAN_SHADOW_SCALE_SHIFT in a Makefile instead of defining
|
||||
+ // it in a header file. Since we're not executing make, we need to set the
|
||||
+ // value manually (values are taken from arch/arm64/Makefile).
|
||||
+ if (kconfig.has_value("CONFIG_KASAN", "y"))
|
||||
+ {
|
||||
+ if (kconfig.has_value("CONFIG_KASAN_SW_TAGS", "y"))
|
||||
+ cflags.push_back("-DKASAN_SHADOW_SCALE_SHIFT=4");
|
||||
+ else
|
||||
+ cflags.push_back("-DKASAN_SHADOW_SCALE_SHIFT=3");
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
return cflags;
|
||||
}
|
||||
|
||||
diff --git a/src/utils.h b/src/utils.h
|
||||
index a76aa161..d4eeac3d 100644
|
||||
--- a/src/utils.h
|
||||
+++ b/src/utils.h
|
||||
@@ -178,7 +178,8 @@ std::tuple<std::string, std::string> get_kernel_dirs(
|
||||
bool unpack_kheaders);
|
||||
std::vector<std::string> get_kernel_cflags(const char *uname_machine,
|
||||
const std::string &ksrc,
|
||||
- const std::string &kobj);
|
||||
+ const std::string &kobj,
|
||||
+ const KConfig &kconfig);
|
||||
std::string get_cgroup_path_in_hierarchy(uint64_t cgroupid,
|
||||
std::string base_path);
|
||||
std::vector<std::pair<std::string, std::string>> get_cgroup_hierarchy_roots();
|
||||
--
|
||||
2.39.2
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
From b23980e4f6ed33d98f4f09ef25ae17baca215cce Mon Sep 17 00:00:00 2001
|
||||
From 8066a715dbd54e6cbfa66176544944a2df7952a6 Mon Sep 17 00:00:00 2001
|
||||
From: Jerome Marchand <jmarchan@redhat.com>
|
||||
Date: Thu, 11 Jun 2020 14:56:36 +0200
|
||||
Subject: [PATCH 6/6] RHEL: aarch64: fixes statsnoop and opensnoop
|
||||
Subject: [PATCH] RHEL: aarch64: fixes statsnoop and opensnoop
|
||||
|
||||
On aarch64 the open syscall has been dropped. Only openat remains,
|
||||
wich is called by libc open() function.
|
||||
|
@ -20,7 +20,7 @@ Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
|
|||
2 files changed, 2 insertions(+), 8 deletions(-)
|
||||
|
||||
diff --git a/tools/opensnoop.bt b/tools/opensnoop.bt
|
||||
index a7de8026..d99db93e 100755
|
||||
index bbb26419..95185e5f 100755
|
||||
--- a/tools/opensnoop.bt
|
||||
+++ b/tools/opensnoop.bt
|
||||
@@ -21,13 +21,11 @@ BEGIN
|
||||
|
@ -30,7 +30,7 @@ index a7de8026..d99db93e 100755
|
|||
-tracepoint:syscalls:sys_enter_open,
|
||||
tracepoint:syscalls:sys_enter_openat
|
||||
{
|
||||
@filename[tid] = args->filename;
|
||||
@filename[tid] = args.filename;
|
||||
}
|
||||
|
||||
-tracepoint:syscalls:sys_exit_open,
|
||||
|
@ -38,11 +38,11 @@ index a7de8026..d99db93e 100755
|
|||
/@filename[tid]/
|
||||
{
|
||||
diff --git a/tools/statsnoop.bt b/tools/statsnoop.bt
|
||||
index b2d529e2..f612ea94 100755
|
||||
index a76b2bcc..89c2c8ea 100755
|
||||
--- a/tools/statsnoop.bt
|
||||
+++ b/tools/statsnoop.bt
|
||||
@@ -30,17 +30,13 @@ tracepoint:syscalls:sys_enter_statfs
|
||||
@filename[tid] = args->pathname;
|
||||
@filename[tid] = args.pathname;
|
||||
}
|
||||
|
||||
-tracepoint:syscalls:sys_enter_statx,
|
||||
|
@ -50,7 +50,7 @@ index b2d529e2..f612ea94 100755
|
|||
-tracepoint:syscalls:sys_enter_newlstat
|
||||
+tracepoint:syscalls:sys_enter_statx
|
||||
{
|
||||
@filename[tid] = args->filename;
|
||||
@filename[tid] = args.filename;
|
||||
}
|
||||
|
||||
tracepoint:syscalls:sys_exit_statfs,
|
||||
|
@ -60,7 +60,7 @@ index b2d529e2..f612ea94 100755
|
|||
+tracepoint:syscalls:sys_exit_statx
|
||||
/@filename[tid]/
|
||||
{
|
||||
$ret = args->ret;
|
||||
$ret = args.ret;
|
||||
--
|
||||
2.35.3
|
||||
2.41.0
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
Name: bpftrace
|
||||
Version: 0.17.0
|
||||
Version: 0.19.1
|
||||
Release: 1%{?dist}
|
||||
Summary: High-level tracing language for Linux eBPF
|
||||
License: ASL 2.0
|
||||
|
@ -13,9 +13,6 @@ Source0: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
|
|||
# for build.
|
||||
Source1: https://github.com/USCiLab/cereal/archive/v%{cereal_version}/cereal-%{cereal_version}.tar.gz
|
||||
|
||||
Patch0: %{name}-%{version}-0001-Parse-kernel-configuration.patch
|
||||
Patch1: %{name}-%{version}-0002-arm64-define-the-KASAN_SHADOW_SCALE_SHIFT-macro.patch
|
||||
|
||||
Patch10: %{name}-%{version}-RHEL-aarch64-fixes-statsnoop-and-opensnoop.patch
|
||||
|
||||
# Arches will be included as upstream support is added and dependencies are
|
||||
|
@ -96,6 +93,14 @@ find %{buildroot}%{_datadir}/%{name}/tools -type f -exec \
|
|||
%exclude %{_datadir}/%{name}/tools/old
|
||||
|
||||
%changelog
|
||||
* Mon Nov 06 2023 Viktor Malik <vmalik@redhat.com> - 0.19.1-1
|
||||
- Rebase on bpftrace 0.19.1 (RHEL-10693)
|
||||
- Rebuild for LLVM 17 (RHEL-10592)
|
||||
- Enhancements and fixes for PowerPC (RHEL-3690, RHEL-11476)
|
||||
|
||||
* Mon May 15 2023 Viktor Malik <vmalik@redhat.com> - 0.17.0-2
|
||||
- Rebuild for LLVM 16 (rhbz#2192953)
|
||||
|
||||
* Tue Mar 14 2023 Viktor Malik <vmalik@redhat.com> - 0.17.0-1
|
||||
- Rebase on bpftrace 0.17.0 (RHEL-286)
|
||||
- Fix runqlat.bt, tcpdrop.bt, and undump.bt on aarch64 (rhbz#2170838)
|
||||
|
|
2
sources
2
sources
|
@ -1,2 +1,2 @@
|
|||
SHA512 (bpftrace-0.17.0.tar.gz) = c3f17778ce4c42c2b6bc63245cd157e9fbc0b3f010b9f5b1284b691fbac47fbb532f3bd61d7e6fe525291e0034d62b3e8c1be6b8bf12cf26d5a39b5ab00a0d13
|
||||
SHA512 (bpftrace-0.19.1.tar.gz) = 2f56b8fb7abfa58631ebc93c7a98cc066446808cbc0116902e43ebefa5f9625232da5ee3ede1d14a236296660a2f4c0907fa1ef24d383b4e32c70dcc3988c765
|
||||
SHA512 (cereal-1.3.2.tar.gz) = 98d306d6292789129675f1c5c5aedcb90cfcc1029c4482893a8f9b23f3c9755e5ed4762d7a528f215345cae6392e87cd8d89467115b6f031b41c8673d6b4b109
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
tags:
|
||||
- classic
|
||||
repositories:
|
||||
- repo: "git://pkgs.devel.redhat.com/tests/bpftrace"
|
||||
- repo: "https://pkgs.devel.redhat.com/git/tests/bpftrace"
|
||||
dest: gating
|
||||
required_packages:
|
||||
- bpftrace
|
||||
|
|
Loading…
Reference in New Issue