Skip to contentSkip to conversation

trace-cmd: Add to ignore event not found error

PATCH In review KOSAKI Motohiro 2 participants 2 messages Jun 29, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace-cmd: Add to ignore event not found error

Usually trace-cmd die If 'trace-cmd start' find wrong -e argument. It mean an admin can't pass the trace point of unloaded kernel module. It can cause nightmare if he manage lots and various computers.

That said, admin want to use the same trace configuration. but, example, some machine loaded ext4 module, others unloaded. It makes harder to reuse.

So, I simply implement ignore option.

---
 trace-cmd.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
trace-cmd.c +8 -3
index cdb0735..b4eb0fe 100644
@@ -113,6 +113,8 @@ struct events {
 
 static struct tracecmd_recorder *recorder;
 
+static int ignore_event_not_found = 0;
+
 static char *get_temp_file(int cpu)
 {
 	char *file = NULL;
@@ -738,7 +740,7 @@ static void update_event(const char *name, const char *filter,
 
 		ret = update_glob(str, filter, filter_only, update);
 		free(str);
-		if (!ret)
+		if (!ret && !ignore_event_not_found)
 			die("No events enabled with %s", name);
 		return;
 	}
@@ -752,7 +754,7 @@ static void update_event(const char *name, const char *filter,
 	ret2 = update_glob(str, filter, filter_only, update);
 	free(str);
 
-	if (!ret && !ret2)
+	if (!ret && !ret2 && !ignore_event_not_found)
 		goto fail;
 
 	return;
@@ -1431,7 +1433,7 @@ int main (int argc, char **argv)
 		   (strcmp(argv[1], "start") == 0) ||
 		   ((extract = strcmp(argv[1], "extract") == 0))) {
 
-		while ((c = getopt(argc-1, argv+1, "+he:f:Fp:do:O:s:r:vg:l:n:P:N:tb:k")) >= 0) {
+		while ((c = getopt(argc-1, argv+1, "+he:f:Fp:do:O:s:r:vg:l:n:P:N:tb:ki")) >= 0) {
 			switch (c) {
 			case 'h':
 				usage(argv);
@@ -1543,6 +1545,9 @@ int main (int argc, char **argv)
 			case 'k':
 				keep = 1;
 				break;
+			case 'i':
+				ignore_event_not_found = 1;
+				break;
 			}
 		}
 
Signature · 1 line
1.6.5.2
#1 lore raw
Quoted 9 lines · KOSAKI Motohiro

Usually trace-cmd die If 'trace-cmd start' find wrong -e argument. It mean an admin can't pass the trace point of unloaded kernel module. It can cause nightmare if he manage lots and various computers.

That said, admin want to use the same trace configuration. but, example, some machine loaded ext4 module, others unloaded. It makes harder to reuse.

So, I simply implement ignore option.

Thanks! I'll pull it and I'll also update the documentation to reflect this change.

-- Steve

Quoted 56 lines
---
 trace-cmd.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
trace-cmd.c +8 -3
index cdb0735..b4eb0fe 100644
@@ -113,6 +113,8 @@ struct events {
 
 static struct tracecmd_recorder *recorder;
 
+static int ignore_event_not_found = 0;
+
 static char *get_temp_file(int cpu)
 {
 	char *file = NULL;
@@ -738,7 +740,7 @@ static void update_event(const char *name, const char *filter,
 
 		ret = update_glob(str, filter, filter_only, update);
 		free(str);
-		if (!ret)
+		if (!ret && !ignore_event_not_found)
 			die("No events enabled with %s", name);
 		return;
 	}
@@ -752,7 +754,7 @@ static void update_event(const char *name, const char *filter,
 	ret2 = update_glob(str, filter, filter_only, update);
 	free(str);
 
-	if (!ret && !ret2)
+	if (!ret && !ret2 && !ignore_event_not_found)
 		goto fail;
 
 	return;
@@ -1431,7 +1433,7 @@ int main (int argc, char **argv)
 		   (strcmp(argv[1], "start") == 0) ||
 		   ((extract = strcmp(argv[1], "extract") == 0))) {
 
-		while ((c = getopt(argc-1, argv+1, "+he:f:Fp:do:O:s:r:vg:l:n:P:N:tb:k")) >= 0) {
+		while ((c = getopt(argc-1, argv+1, "+he:f:Fp:do:O:s:r:vg:l:n:P:N:tb:ki")) >= 0) {
 			switch (c) {
 			case 'h':
 				usage(argv);
@@ -1543,6 +1545,9 @@ int main (int argc, char **argv)
 			case 'k':
 				keep = 1;
 				break;
+			case 'i':
+				ignore_event_not_found = 1;
+				break;
 			}
 		}