Hemant Kumar <hemant@xxxxxxxxxxxxxxxxxx> writes:
First I should say supporting these probes is very useful. Thanks for
working on this.
+This requires running perf as root, right?
+#define SDT_CACHE_DIR "/var/cache/perf/"
It would be better to use the $HOME cache dir, like the recent JSON patches.
+#define SDT_CACHE "perf-sdt.cache"The function seems redundant.
+#define SDT_CACHE_TMP "perf-sdt.cache.tmp"
+
+#define DELIM ':'
+
+struct path_list {
+ char path[PATH_MAX];
+ struct list_head list;
+} execs;
+
+/* Write operation for cache */
+static void write_cache(FILE *cache, char *buffer)
+{
+ fprintf(cache, "%s", buffer);
+}
+
+/*pr_info ?
+ * get_sdt_note_info() is the function actually responsible for
+ * flushing the SDT notes info into the "cache" file or to the
+ * stdout if "cache" points to NULL. Also, this function finds out
+ * the build-id of an ELF to be written into "cache".
+ */
+static void get_sdt_note_info(struct list_head *start, const char *target,
+ FILE *cache)
+{
+ struct sdt_note *pos;
+ u8 build_id[BUILD_ID_SIZE];
+ char sbuild_id[BUILD_ID_SIZE * 2 + 1];
+ char buffer[2 * PATH_MAX];
+
+ if (list_empty(start))
+ return;
+
+ /* Read the build id of the file */
+ if (filename__read_build_id(target, &build_id,
+ sizeof(build_id)) < 0) {
+ pr_debug("Couldn't read build-id in %s\n", target);
+This seems like a hack. How would that handle chroot, containers etc. ?
+/*
+ * Finds out the libraries present in a system as shown by the command
+ * "ldconfig --print-cache". Uses "=>" and '/' to find out the start of a
+ * dso path.
+ */
+static inline void append_path(char *path, struct list_head *list)
+{
+ char *res_path = NULL;
+ struct path_list *tmp = NULL;
+
+ res_path = (char *)malloc(sizeof(char) * PATH_MAX);
+
+ if (!res_path)
+ return;
+
+ memset(res_path, '\0', PATH_MAX);
+
+ if (realpath(path, res_path) && !is_present_in_list(list, res_path)) {
O^2 algorithm ?
+/*Same as above. This probably needs to be more configurable to handle
+ * Obtain the list of paths from the PATH env variable
+ */
more ways to find binaries.