diff options
author | Steven Rostedt <srostedt@redhat.com> | 2009-11-16 23:38:11 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2009-11-16 23:51:19 -0500 |
commit | 86901b1b7dd164e85246c7083a75de7904edcb7f (patch) | |
tree | 307eebd3c5ddae645a5e82ecc273d11f2c9abdf8 | |
parent | 32ba4ff2b06810f2fa32f4e9fdc347229b7845f3 (diff) |
don't fail if ftrace_enable is not there
We should still be able to do tracing if the kernel was not compiled
with function tracer. Don't fail on failure to read ftrace_enable.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-cmd.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/trace-cmd.c b/trace-cmd.c index 22c3df6..77ce277 100644 --- a/trace-cmd.c +++ b/trace-cmd.c | |||
@@ -289,17 +289,26 @@ static int find_trace_type(const char *type) | |||
289 | return ret > 0; | 289 | return ret > 0; |
290 | } | 290 | } |
291 | 291 | ||
292 | static void set_ftrace(int set) | 292 | static int set_ftrace(int set) |
293 | { | 293 | { |
294 | struct stat buf; | ||
295 | char *path = "/proc/sys/kernel/ftrace_enabled"; | ||
294 | int fd; | 296 | int fd; |
295 | char *val = set ? "1" : "0"; | 297 | char *val = set ? "1" : "0"; |
296 | 298 | ||
297 | fd = open("/proc/sys/kernel/ftrace_enabled", O_WRONLY); | 299 | /* if ftace_enable does not exist, simply ignore it */ |
300 | fd = stat(path, &buf); | ||
301 | if (fd < 0) | ||
302 | return -ENODEV; | ||
303 | |||
304 | fd = open(path, O_WRONLY); | ||
298 | if (fd < 0) | 305 | if (fd < 0) |
299 | die ("Can't %s ftrace", set ? "enable" : "disable"); | 306 | die ("Can't %s ftrace", set ? "enable" : "disable"); |
300 | 307 | ||
301 | write(fd, val, 1); | 308 | write(fd, val, 1); |
302 | close(fd); | 309 | close(fd); |
310 | |||
311 | return 0; | ||
303 | } | 312 | } |
304 | 313 | ||
305 | void run_cmd(int argc, char **argv) | 314 | void run_cmd(int argc, char **argv) |
@@ -1101,6 +1110,7 @@ int main (int argc, char **argv) | |||
1101 | int plug = 0; | 1110 | int plug = 0; |
1102 | int events = 0; | 1111 | int events = 0; |
1103 | int options = 0; | 1112 | int options = 0; |
1113 | int fset; | ||
1104 | 1114 | ||
1105 | int c; | 1115 | int c; |
1106 | 1116 | ||
@@ -1201,7 +1211,7 @@ int main (int argc, char **argv) | |||
1201 | 1211 | ||
1202 | read_tracing_data(); | 1212 | read_tracing_data(); |
1203 | 1213 | ||
1204 | set_ftrace(!disable); | 1214 | fset = set_ftrace(!disable); |
1205 | 1215 | ||
1206 | disable_all(); | 1216 | disable_all(); |
1207 | 1217 | ||
@@ -1224,6 +1234,9 @@ int main (int argc, char **argv) | |||
1224 | latency = 1; | 1234 | latency = 1; |
1225 | stop_threads(); | 1235 | stop_threads(); |
1226 | } | 1236 | } |
1237 | if (fset < 0 && (strcmp(plugin, "function") == 0 || | ||
1238 | strcmp(plugin, "function_graph") == 0)) | ||
1239 | die("function tracing not configured on this kernel"); | ||
1227 | set_plugin(plugin); | 1240 | set_plugin(plugin); |
1228 | } | 1241 | } |
1229 | 1242 | ||