aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-03-18 09:23:12 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-03-18 09:23:12 -0400
commit9c894c507392ee73628548ad832b008f296b16d6 (patch)
tree6cde404728e29e70fac3152790f204fc70faff58
parent7356927f3218e1d49c416acf80afeac313a817d9 (diff)
trace-cmd: Error on record if plugin given does not exist
If a bad event is given, trace-cmd record fails. But if a bad plugin name is given it continues and does nothing. If a bad plugin name is given it should fail and report an error. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-record.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/trace-record.c b/trace-record.c
index 4309c7e..1ad1e19 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -1844,6 +1844,26 @@ void set_buffer_size(void)
1844 close(fd); 1844 close(fd);
1845} 1845}
1846 1846
1847static void check_plugin(const char *plugin)
1848{
1849 char *buf;
1850 char *tok;
1851
1852 buf = read_file("available_tracers", NULL);
1853 if (!buf)
1854 die("No plugins available");
1855
1856 while ((tok = strtok(buf, " "))) {
1857 buf = NULL;
1858 if (strcmp(tok, plugin) == 0)
1859 goto out;
1860 }
1861 die ("Plugin '%s' does not exist", plugin);
1862 out:
1863 fprintf(stderr, " plugin '%s'\n", plugin);
1864 free(buf);
1865}
1866
1847static void record_all_events(void) 1867static void record_all_events(void)
1848{ 1868{
1849 struct tracecmd_event_list *list; 1869 struct tracecmd_event_list *list;
@@ -2011,7 +2031,11 @@ void trace_record (int argc, char **argv)
2011 die("only one plugin allowed"); 2031 die("only one plugin allowed");
2012 for (plugin = optarg; isspace(*plugin); plugin++) 2032 for (plugin = optarg; isspace(*plugin); plugin++)
2013 ; 2033 ;
2014 fprintf(stderr, " plugin %s\n", plugin); 2034 for (optarg += strlen(optarg) - 1;
2035 optarg > plugin && isspace(*optarg); optarg--)
2036 ;
2037 optarg++;
2038 optarg[0] = '\0';
2015 break; 2039 break;
2016 case 'd': 2040 case 'd':
2017 if (extract) 2041 if (extract)
@@ -2123,6 +2147,8 @@ void trace_record (int argc, char **argv)
2123 } 2147 }
2124 2148
2125 if (plugin) { 2149 if (plugin) {
2150
2151 check_plugin(plugin);
2126 /* 2152 /*
2127 * Latency tracers just save the trace and kill 2153 * Latency tracers just save the trace and kill
2128 * the threads. 2154 * the threads.