* [ltt-dev] [UST PATCH] Allow backward compatibility to ustctl <= 0.11 for some commands
@ 2011-02-24 15:46 Jason Wessel
2011-02-24 19:59 ` Nils Carlson
0 siblings, 1 reply; 4+ messages in thread
From: Jason Wessel @ 2011-02-24 15:46 UTC (permalink / raw)
The rewrite of the ustctl broke all the existing scripts
that make use of ustctl. This allows the original commands,
examples, and external scripts to continue working properly.
This covers the commands:
--list-markers
--list-trace-events
--alloc-trace
--start-trace
--stop-trace
--create-trace
--destroy-trace
--enable-marker
--disable-marker
Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
---
ustctl/ustctl.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 71 insertions(+), 3 deletions(-)
diff --git a/ustctl/ustctl.c b/ustctl/ustctl.c
index c1bbe8c..5463a1c 100644
--- a/ustctl/ustctl.c
+++ b/ustctl/ustctl.c
@@ -45,8 +45,40 @@ void usage(const char *process_name)
list_cli_cmds(CLI_DESCRIPTIVE_LIST);
}
+#define DASH_DASH_COMPAT 1
+#ifdef DASH_DASH_COMPAT
+/*
+ * If DASH_DASH_COMPAT is defined allow the some of the ustctl command
+ * in version <= 0.11 commands to live on a while longer such that
+ * scripts do not immediately have to be changed.
+ */
+enum command {
+ CREATE_TRACE=1000,
+ ALLOC_TRACE,
+ START_TRACE,
+ STOP_TRACE,
+ DESTROY_TRACE,
+ LIST_MARKERS,
+ LIST_TRACE_EVENTS,
+ ENABLE_MARKER,
+ DISABLE_MARKER,
+};
+
+#endif /* DASH_DASH_COMPAT */
+
struct option options[] =
{
+#ifdef DASH_DASH_COMPAT
+ { "create-trace", 0, 0, CREATE_TRACE },
+ { "alloc-trace", 0, 0, ALLOC_TRACE },
+ { "start-trace", 0, 0, START_TRACE },
+ { "stop-trace", 0, 0, STOP_TRACE },
+ { "destroy-trace", 0, 0, DESTROY_TRACE },
+ { "list-markers", 0, 0, LIST_MARKERS },
+ { "list-trace-events", 0, 0, LIST_TRACE_EVENTS},
+ { "enable-marker", 0, 0, ENABLE_MARKER },
+ { "disable-marker", 0, 0, DISABLE_MARKER },
+#endif /* DASH_DASH_COMPAT */
{"help", 2, NULL, 'h'},
{"list", 0, NULL, 'l'},
{"extended-list", 0, NULL, 'e'},
@@ -56,6 +88,7 @@ struct option options[] =
int main(int argc, char *argv[])
{
struct cli_cmd *cli_cmd;
+ char **args = argv;
int opt;
if(argc <= 1) {
@@ -85,20 +118,55 @@ int main(int argc, char *argv[])
case 'e':
list_cli_cmds(CLI_EXTENDED_LIST);
exit(EXIT_FAILURE);
+#ifdef DASH_DASH_COMPAT
+ case LIST_MARKERS:
+ case LIST_TRACE_EVENTS:
+ case CREATE_TRACE:
+ case ALLOC_TRACE:
+ case START_TRACE:
+ case STOP_TRACE:
+ case DESTROY_TRACE:
+ case ENABLE_MARKER:
+ case DISABLE_MARKER:
+ {
+ int i;
+ args = (char **)malloc(sizeof(char **) * argc + 3);
+ optind--;
+ args[optind] = strdup(&argv[optind][2]);
+ for (i = optind + 1; i < argc; i++) {
+ args[i] = argv[i];
+ }
+ if (opt >= CREATE_TRACE && opt <= DESTROY_TRACE) {
+ args[argc] = strdup("auto");
+ argc++;
+ }
+ if (opt >= ENABLE_MARKER && opt <= DISABLE_MARKER) {
+ args[argc] = args[argc - 2];
+ args[argc - 2] = args[argc - 1];
+ args[argc - 1] = strdup("auto");
+ argc++;
+ }
+ args[argc] = NULL;
+ goto do_cli;
+ }
+#endif /* DASH_DASH_COMPAT */
default:
fprintf(stderr, "Unknown option\n");
break;
}
}
- cli_cmd = find_cli_cmd(argv[optind]);
+#ifdef DASH_DASH_COMPAT
+do_cli:
+#endif /* DASH_DASH_COMPAT */
+ cli_cmd = find_cli_cmd(args[optind]);
if (!cli_cmd) {
fprintf(stderr, "No such command %s\n",
- argv[optind]);
+ args[optind]);
exit(EXIT_FAILURE);
}
- cli_dispatch_cmd(cli_cmd, argc - optind, &argv[optind]);
+ cli_dispatch_cmd(cli_cmd, argc - optind, &args[optind]);
return 0;
}
--
1.6.6.2
^ permalink raw reply [flat|nested] 4+ messages in thread* [ltt-dev] [UST PATCH] Allow backward compatibility to ustctl <= 0.11 for some commands
2011-02-24 15:46 [ltt-dev] [UST PATCH] Allow backward compatibility to ustctl <= 0.11 for some commands Jason Wessel
@ 2011-02-24 19:59 ` Nils Carlson
2011-02-24 20:11 ` Jason Wessel
0 siblings, 1 reply; 4+ messages in thread
From: Nils Carlson @ 2011-02-24 19:59 UTC (permalink / raw)
Hi,
Any reason you want to ifdef these? The idea with the new api was to
make it nicer, but I wouldn't mind being backwards compatible as well.
If its ok with you I can pull this patch tomorrow and remove the
#ifdefs?
/Nils
On Feb 24, 2011, at 4:46 PM, Jason Wessel wrote:
> The rewrite of the ustctl broke all the existing scripts
> that make use of ustctl. This allows the original commands,
> examples, and external scripts to continue working properly.
>
> This covers the commands:
>
> --list-markers
> --list-trace-events
> --alloc-trace
> --start-trace
> --stop-trace
> --create-trace
> --destroy-trace
> --enable-marker
> --disable-marker
>
> Signed-off-by: Jason Wessel <jason.wessel at windriver.com>
> ---
> ustctl/ustctl.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++
> ++++++--
> 1 files changed, 71 insertions(+), 3 deletions(-)
>
> diff --git a/ustctl/ustctl.c b/ustctl/ustctl.c
> index c1bbe8c..5463a1c 100644
> --- a/ustctl/ustctl.c
> +++ b/ustctl/ustctl.c
> @@ -45,8 +45,40 @@ void usage(const char *process_name)
> list_cli_cmds(CLI_DESCRIPTIVE_LIST);
> }
>
> +#define DASH_DASH_COMPAT 1
> +#ifdef DASH_DASH_COMPAT
> +/*
> + * If DASH_DASH_COMPAT is defined allow the some of the ustctl
> command
> + * in version <= 0.11 commands to live on a while longer such that
> + * scripts do not immediately have to be changed.
> + */
> +enum command {
> + CREATE_TRACE=1000,
> + ALLOC_TRACE,
> + START_TRACE,
> + STOP_TRACE,
> + DESTROY_TRACE,
> + LIST_MARKERS,
> + LIST_TRACE_EVENTS,
> + ENABLE_MARKER,
> + DISABLE_MARKER,
> +};
> +
> +#endif /* DASH_DASH_COMPAT */
> +
> struct option options[] =
> {
> +#ifdef DASH_DASH_COMPAT
> + { "create-trace", 0, 0, CREATE_TRACE },
> + { "alloc-trace", 0, 0, ALLOC_TRACE },
> + { "start-trace", 0, 0, START_TRACE },
> + { "stop-trace", 0, 0, STOP_TRACE },
> + { "destroy-trace", 0, 0, DESTROY_TRACE },
> + { "list-markers", 0, 0, LIST_MARKERS },
> + { "list-trace-events", 0, 0, LIST_TRACE_EVENTS},
> + { "enable-marker", 0, 0, ENABLE_MARKER },
> + { "disable-marker", 0, 0, DISABLE_MARKER },
> +#endif /* DASH_DASH_COMPAT */
> {"help", 2, NULL, 'h'},
> {"list", 0, NULL, 'l'},
> {"extended-list", 0, NULL, 'e'},
> @@ -56,6 +88,7 @@ struct option options[] =
> int main(int argc, char *argv[])
> {
> struct cli_cmd *cli_cmd;
> + char **args = argv;
> int opt;
>
> if(argc <= 1) {
> @@ -85,20 +118,55 @@ int main(int argc, char *argv[])
> case 'e':
> list_cli_cmds(CLI_EXTENDED_LIST);
> exit(EXIT_FAILURE);
> +#ifdef DASH_DASH_COMPAT
> + case LIST_MARKERS:
> + case LIST_TRACE_EVENTS:
> + case CREATE_TRACE:
> + case ALLOC_TRACE:
> + case START_TRACE:
> + case STOP_TRACE:
> + case DESTROY_TRACE:
> + case ENABLE_MARKER:
> + case DISABLE_MARKER:
> + {
> + int i;
> + args = (char **)malloc(sizeof(char **) * argc + 3);
> + optind--;
> + args[optind] = strdup(&argv[optind][2]);
> + for (i = optind + 1; i < argc; i++) {
> + args[i] = argv[i];
> + }
> + if (opt >= CREATE_TRACE && opt <= DESTROY_TRACE) {
> + args[argc] = strdup("auto");
> + argc++;
> + }
> + if (opt >= ENABLE_MARKER && opt <= DISABLE_MARKER) {
> + args[argc] = args[argc - 2];
> + args[argc - 2] = args[argc - 1];
> + args[argc - 1] = strdup("auto");
> + argc++;
> + }
> + args[argc] = NULL;
> + goto do_cli;
> + }
> +#endif /* DASH_DASH_COMPAT */
> default:
> fprintf(stderr, "Unknown option\n");
> break;
> }
> }
>
> - cli_cmd = find_cli_cmd(argv[optind]);
> +#ifdef DASH_DASH_COMPAT
> +do_cli:
> +#endif /* DASH_DASH_COMPAT */
> + cli_cmd = find_cli_cmd(args[optind]);
> if (!cli_cmd) {
> fprintf(stderr, "No such command %s\n",
> - argv[optind]);
> + args[optind]);
> exit(EXIT_FAILURE);
> }
>
> - cli_dispatch_cmd(cli_cmd, argc - optind, &argv[optind]);
> + cli_dispatch_cmd(cli_cmd, argc - optind, &args[optind]);
>
> return 0;
> }
> --
> 1.6.6.2
>
>
> _______________________________________________
> ltt-dev mailing list
> ltt-dev at lists.casi.polymtl.ca
> http://lists.casi.polymtl.ca/cgi-bin/mailman/listinfo/ltt-dev
^ permalink raw reply [flat|nested] 4+ messages in thread* [ltt-dev] [UST PATCH] Allow backward compatibility to ustctl <= 0.11 for some commands
2011-02-24 19:59 ` Nils Carlson
@ 2011-02-24 20:11 ` Jason Wessel
2011-02-24 22:29 ` Mathieu Desnoyers
0 siblings, 1 reply; 4+ messages in thread
From: Jason Wessel @ 2011-02-24 20:11 UTC (permalink / raw)
On 02/24/2011 01:59 PM, Nils Carlson wrote:
> Hi,
>
> Any reason you want to ifdef these? The idea with the new api was to
> make it nicer, but I wouldn't mind being backwards compatible as well.
>
> If its ok with you I can pull this patch tomorrow and remove the
> #ifdefs?
>
I put the #ifdef's in to show that it is cleanly implemented as per the requirement of Mathieu.
I'll gladly send another patch with the #ifdef's removed and move the allocation of "int i" up with the other variables.
Jason.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ltt-dev] [UST PATCH] Allow backward compatibility to ustctl <= 0.11 for some commands
2011-02-24 20:11 ` Jason Wessel
@ 2011-02-24 22:29 ` Mathieu Desnoyers
0 siblings, 0 replies; 4+ messages in thread
From: Mathieu Desnoyers @ 2011-02-24 22:29 UTC (permalink / raw)
* Jason Wessel (jason.wessel at windriver.com) wrote:
> On 02/24/2011 01:59 PM, Nils Carlson wrote:
> > Hi,
> >
> > Any reason you want to ifdef these? The idea with the new api was to
> > make it nicer, but I wouldn't mind being backwards compatible as well.
> >
> > If its ok with you I can pull this patch tomorrow and remove the
> > #ifdefs?
> >
>
>
> I put the #ifdef's in to show that it is cleanly implemented as per the requirement of Mathieu.
>
> I'll gladly send another patch with the #ifdef's removed and move the allocation of "int i" up with the other variables.
That's fine with me, and it would still be clean enough. ;)
Thanks!
Mathieu
>
> Jason.
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-02-24 22:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-24 15:46 [ltt-dev] [UST PATCH] Allow backward compatibility to ustctl <= 0.11 for some commands Jason Wessel
2011-02-24 19:59 ` Nils Carlson
2011-02-24 20:11 ` Jason Wessel
2011-02-24 22:29 ` Mathieu Desnoyers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox