builtin-probe.c (225466f1c2d816c33b4341008f45dfdc83a9f0cb) builtin-probe.c (73eff9f56e15598c8399c0b86899fd889b97f085)
1/*
2 * builtin-probe.c
3 *
4 * Builtin probe command: Set up probe events by C expression
5 *
6 * Written by Masami Hiramatsu <mhiramat@redhat.com>
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 71 unchanged lines hidden (view full) ---

80
81 /* Parse a perf-probe command into event */
82 ret = parse_perf_probe_command(str, pev);
83 pr_debug("%d arguments\n", pev->nargs);
84
85 return ret;
86}
87
1/*
2 * builtin-probe.c
3 *
4 * Builtin probe command: Set up probe events by C expression
5 *
6 * Written by Masami Hiramatsu <mhiramat@redhat.com>
7 *
8 * This program is free software; you can redistribute it and/or modify

--- 71 unchanged lines hidden (view full) ---

80
81 /* Parse a perf-probe command into event */
82 ret = parse_perf_probe_command(str, pev);
83 pr_debug("%d arguments\n", pev->nargs);
84
85 return ret;
86}
87
88static int set_target(const char *ptr)
89{
90 int found = 0;
91 const char *buf;
92
93 /*
94 * The first argument after options can be an absolute path
95 * to an executable / library or kernel module.
96 *
97 * TODO: Support relative path, and $PATH, $LD_LIBRARY_PATH,
98 * short module name.
99 */
100 if (!params.target && ptr && *ptr == '/') {
101 params.target = ptr;
102 found = 1;
103 buf = ptr + (strlen(ptr) - 3);
104
105 if (strcmp(buf, ".ko"))
106 params.uprobes = true;
107
108 }
109
110 return found;
111}
112
88static int parse_probe_event_argv(int argc, const char **argv)
89{
113static int parse_probe_event_argv(int argc, const char **argv)
114{
90 int i, len, ret;
115 int i, len, ret, found_target;
91 char *buf;
92
116 char *buf;
117
118 found_target = set_target(argv[0]);
119 if (found_target && argc == 1)
120 return 0;
121
93 /* Bind up rest arguments */
94 len = 0;
122 /* Bind up rest arguments */
123 len = 0;
95 for (i = 0; i < argc; i++)
124 for (i = 0; i < argc; i++) {
125 if (i == 0 && found_target)
126 continue;
127
96 len += strlen(argv[i]) + 1;
128 len += strlen(argv[i]) + 1;
129 }
97 buf = zalloc(len + 1);
98 if (buf == NULL)
99 return -ENOMEM;
100 len = 0;
130 buf = zalloc(len + 1);
131 if (buf == NULL)
132 return -ENOMEM;
133 len = 0;
101 for (i = 0; i < argc; i++)
134 for (i = 0; i < argc; i++) {
135 if (i == 0 && found_target)
136 continue;
137
102 len += sprintf(&buf[len], "%s ", argv[i]);
138 len += sprintf(&buf[len], "%s ", argv[i]);
139 }
103 params.mod_events = true;
104 ret = parse_probe_event(buf);
105 free(buf);
106 return ret;
107}
108
109static int opt_add_probe_event(const struct option *opt __used,
110 const char *str, int unset __used)

--- 325 unchanged lines hidden ---
140 params.mod_events = true;
141 ret = parse_probe_event(buf);
142 free(buf);
143 return ret;
144}
145
146static int opt_add_probe_event(const struct option *opt __used,
147 const char *str, int unset __used)

--- 325 unchanged lines hidden ---