6 #include <linux/filter.h> 13 #if defined(HAVE_SDT_EVENT) && defined(HAVE_LIBELF_SUPPORT) 17 static int target_function(
void)
19 DTRACE_PROBE(
perf, test_target);
32 pr_debug(
"Failed to read build id of %s\n", filename);
39 pr_debug(
"Failed to add build id cache of %s\n", filename);
43 static char *get_self_path(
void)
45 char *buf = calloc(
PATH_MAX,
sizeof(
char));
47 if (buf && readlink(
"/proc/self/exe", buf,
PATH_MAX - 1) < 0) {
48 pr_debug(
"Failed to get correct path of perf\n");
55 static int search_cached_probe(
const char *
target,
62 pr_debug(
"Failed to open probe cache of %s\n", target);
67 pr_debug(
"Failed to find %s:%s in the cache\n", group, event);
78 char __tempdir[] =
"./test-buildid-XXXXXX";
79 char *tempdir = NULL, *myself = get_self_path();
81 if (myself == NULL || mkdtemp(__tempdir) == NULL) {
82 pr_debug(
"Failed to make a tempdir for build-id cache\n");
86 tempdir = realpath(__tempdir, NULL);
96 if (search_cached_probe(myself,
"sdt_perf",
"test_target") < 0)
102 ret = target_function();
115 pr_debug(
"Skip SDT event test because SDT support is not compiled\n");
int build_id_cache__add_s(const char *sbuild_id, const char *name, struct nsinfo *nsi, bool is_kallsyms, bool is_vdso)
int filename__read_build_id(const char *filename, void *bf, size_t size)
void set_buildid_dir(const char *dir)
int rm_rf(const char *path)
#define pr_debug(fmt,...)
struct probe_cache * probe_cache__new(const char *target, struct nsinfo *nsi)
void probe_cache__delete(struct probe_cache *pcache)
struct probe_cache_entry * probe_cache__find_by_name(struct probe_cache *pcache, const char *group, const char *event)
static int build_id_cache__add_file(const char *filename, struct nsinfo *nsi)
int build_id__sprintf(const u8 *build_id, int len, char *bf)
int test__sdt_event(struct test *test __maybe_unused, int subtests __maybe_unused)