X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=ustctl%2Fustctl.c;h=35bea7ae6b3d84f17c1493e378593149f4b6e90c;hb=1e620c5350cfbd0b0be4122547115dd4da503bcf;hp=3ff2fb78e16398ee78a9a6be60a5955a1aca1298;hpb=62ec620f40891af46d0ee4768992275dc7b28433;p=ust.git diff --git a/ustctl/ustctl.c b/ustctl/ustctl.c index 3ff2fb7..35bea7a 100644 --- a/ustctl/ustctl.c +++ b/ustctl/ustctl.c @@ -22,20 +22,26 @@ #include #include -#include "ustcomm.h" -#include "ustcmd.h" +#include "ust/ustcmd.h" #include "usterr.h" enum command { - CREATE_TRACE, + CREATE_TRACE=1000, + ALLOC_TRACE, START_TRACE, STOP_TRACE, - START, - DESTROY, + DESTROY_TRACE, LIST_MARKERS, ENABLE_MARKER, DISABLE_MARKER, GET_ONLINE_PIDS, + SET_SUBBUF_SIZE, + SET_SUBBUF_NUM, + GET_SUBBUF_SIZE, + GET_SUBBUF_NUM, + GET_SOCK_PATH, + SET_SOCK_PATH, + FORCE_SWITCH, UNKNOWN }; @@ -54,12 +60,20 @@ void usage(void) \n\ Commands:\n\ --create-trace\t\t\tCreate trace\n\ + --alloc-trace\t\t\tAlloc trace\n\ --start-trace\t\t\tStart tracing\n\ --stop-trace\t\t\tStop tracing\n\ --destroy-trace\t\t\tDestroy the trace\n\ + --set-subbuf-size \"CHANNEL/bytes\"\tSet the size of subbuffers per channel\n\ + --set-subbuf-num \"CHANNEL/n\"\tSet the number of subbuffers per channel\n\ + --set-sock-path\t\t\tSet the path of the daemon socket\n\ + --get-subbuf-size \"CHANNEL\"\t\tGet the size of subbuffers per channel\n\ + --get-subbuf-num \"CHANNEL\"\t\tGet the number of subbuffers per channel\n\ + --get-sock-path\t\t\tGet the path of the daemon socket\n\ --enable-marker \"CHANNEL/MARKER\"\tEnable a marker\n\ --disable-marker \"CHANNEL/MARKER\"\tDisable a marker\n\ --list-markers\t\t\tList the markers of the process, their\n\t\t\t\t\t state and format string\n\ + --force-switch\t\t\tForce a subbuffer switch\n\ \ "); } @@ -74,26 +88,33 @@ int parse_opts_long(int argc, char **argv, struct ust_opts *opts) while (1) { int option_index = 0; static struct option long_options[] = { - {"create-trace", 0, 0, 1012}, - {"start-trace", 0, 0, 1000}, - {"stop-trace", 0, 0, 1001}, - {"destroy-trace", 0, 0, 1002}, - {"list-markers", 0, 0, 1004}, - {"print-markers", 0, 0, 1005}, - {"pid", 1, 0, 1006}, - {"enable-marker", 1, 0, 1007}, - {"disable-marker", 1, 0, 1008}, - {"start", 0, 0, 1009}, - {"help", 0, 0, 'h'}, - {"version", 0, 0, 1010}, - {"online-pids", 0, 0, 1011}, - {0, 0, 0, 0} + { "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 }, + { "enable-marker", 1, 0, ENABLE_MARKER }, + { "disable-marker", 1, 0, DISABLE_MARKER }, + { "help", 0, 0, 'h' }, + { "online-pids", 0, 0, GET_ONLINE_PIDS }, + { "set-subbuf-size", 1, 0, SET_SUBBUF_SIZE }, + { "set-subbuf-num", 1, 0, SET_SUBBUF_NUM }, + { "get-subbuf-size", 1, 0, GET_SUBBUF_SIZE }, + { "get-subbuf-num", 1, 0, GET_SUBBUF_NUM }, + { "get-sock-path", 0, 0, GET_SOCK_PATH }, + { "set-sock-path", 1, 0, SET_SOCK_PATH }, + { "force-switch", 0, 0, FORCE_SWITCH }, + { 0, 0, 0, 0 } }; c = getopt_long(argc, argv, "h", long_options, &option_index); if (c == -1) break; + if(c >= 1000) + opts->cmd = c; + switch (c) { case 0: printf("option %s", long_options[option_index].name); @@ -102,53 +123,31 @@ int parse_opts_long(int argc, char **argv, struct ust_opts *opts) printf("\n"); break; - case 1000: - opts->cmd = START_TRACE; - break; - case 1001: - opts->cmd = STOP_TRACE; - break; - case 1009: - opts->cmd = START; - break; - case 1002: - opts->cmd = DESTROY; - break; - case 1004: - opts->cmd = LIST_MARKERS; - break; - case 1007: - opts->cmd = ENABLE_MARKER; - opts->regex = strdup(optarg); - break; - case 1008: - opts->cmd = DISABLE_MARKER; + case ENABLE_MARKER: + case DISABLE_MARKER: + case SET_SUBBUF_SIZE: + case SET_SUBBUF_NUM: + case GET_SUBBUF_SIZE: + case GET_SUBBUF_NUM: + case SET_SOCK_PATH: opts->regex = strdup(optarg); break; - case 1011: - opts->cmd = GET_ONLINE_PIDS; - break; + case 'h': usage(); exit(0); - case 1010: - printf("Version 0.1\n"); - break; - case 1012: - opts->cmd = CREATE_TRACE; - break; - default: - /* unknown option or other error; error is - printed by getopt, just return */ - opts->cmd = UNKNOWN; - return 1; + + case '?': + fprintf(stderr, "Invalid argument\n\n"); + usage(); + exit(1); } } if (argc - optind > 0 && opts->cmd != GET_ONLINE_PIDS) { int i; int pididx=0; - opts->pids = malloc((argc-optind+1) * sizeof(pid_t)); + opts->pids = zmalloc((argc-optind+1) * sizeof(pid_t)); for(i=optind; i