#define MAX_PROBE_ARGS 128
#define PERFPROBE_GROUP "probe"
+bool probe_event_dry_run; /* Dry run flag */
+
#define semantic_error(msg ...) die("Semantic error :" msg)
/* If there is no space to write, returns -E2BIG. */
return ret;
}
-static int open_kprobe_events(int flags, int mode)
+static int open_kprobe_events(bool readwrite)
{
char buf[PATH_MAX];
int ret;
if (ret < 0)
die("Failed to make kprobe_events path.");
- ret = open(buf, flags, mode);
+ if (readwrite && !probe_event_dry_run)
+ ret = open(buf, O_RDWR, O_APPEND);
+ else
+ ret = open(buf, O_RDONLY, 0);
+
if (ret < 0) {
if (errno == ENOENT)
die("kprobe_events file does not exist -"
setup_pager();
memset(&pp, 0, sizeof(pp));
- fd = open_kprobe_events(O_RDONLY, 0);
+ fd = open_kprobe_events(false);
rawlist = get_trace_kprobe_event_rawlist(fd);
close(fd);
int ret;
pr_debug("Writing event: %s\n", buf);
- ret = write(fd, buf, strlen(buf));
- if (ret <= 0)
- die("Failed to write event: %s", strerror(errno));
+ if (!probe_event_dry_run) {
+ ret = write(fd, buf, strlen(buf));
+ if (ret <= 0)
+ die("Failed to write event: %s", strerror(errno));
+ }
}
static void get_new_event_name(char *buf, size_t len, const char *base,
struct strlist *namelist;
bool allow_suffix;
- fd = open_kprobe_events(O_RDWR, O_APPEND);
+ fd = open_kprobe_events(true);
/* Get current event names */
namelist = get_perf_event_names(fd, false);
struct str_node *ent;
struct strlist *namelist;
- fd = open_kprobe_events(O_RDWR, O_APPEND);
+ fd = open_kprobe_events(true);
/* Get current event names */
namelist = get_perf_event_names(fd, true);