add a command to force subbuffer switch
[ust.git] / ustctl / ustctl.c
index 0e8e01d236de2eec52231bdd8c63f7dd594b6bd6..b9f2dce83b43913bc6aaedd766d160d9a81accdb 100644 (file)
@@ -38,6 +38,11 @@ enum command {
        GET_ONLINE_PIDS,
        SET_SUBBUF_SIZE,
        SET_SUBBUF_NUM,
+       GET_SUBBUF_SIZE,
+       GET_SUBBUF_NUM,
+       GET_SOCK_PATH,
+       SET_SOCK_PATH,
+       FORCE_SWITCH,
        UNKNOWN
 };
 
@@ -56,14 +61,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\
 \
 ");
 }
@@ -90,6 +101,11 @@ int parse_opts_long(int argc, char **argv, struct ust_opts *opts)
                        { "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 }
                };
 
@@ -112,6 +128,9 @@ int parse_opts_long(int argc, char **argv, struct ust_opts *opts)
                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;
 
@@ -152,6 +171,7 @@ int main(int argc, char *argv[])
 {
        pid_t *pidit;
        int result;
+       char *tmp;
        struct ust_opts opts;
 
        progname = argv[0];
@@ -270,6 +290,26 @@ int main(int argc, char *argv[])
                                ustcmd_set_subbuf_num(opts.regex, *pidit);
                                break;
 
+                       case GET_SUBBUF_SIZE:
+                               result = ustcmd_get_subbuf_size(opts.regex, *pidit);
+                               if (result == -1) {
+                                       ERR("error while trying to get_subuf_size with PID %u\n", (unsigned int) *pidit);
+                                       break;
+                               }
+
+                               printf("the size of subbufers is %d\n", result);
+                               break;
+
+                       case GET_SUBBUF_NUM:
+                               result = ustcmd_get_subbuf_num(opts.regex, *pidit);
+                               if (result == -1) {
+                                       ERR("error while trying to get_subuf_num with PID %u\n", (unsigned int) *pidit);
+                                       break;
+                               }
+
+                               printf("the number of subbufers is %d\n", result);
+                               break;
+
                        case ALLOC_TRACE:
                                result = ustcmd_alloc_trace(*pidit);
                                if (result) {
@@ -278,6 +318,30 @@ int main(int argc, char *argv[])
                                }
                                break;
 
+                       case GET_SOCK_PATH:
+                               result = ustcmd_get_sock_path(&tmp, *pidit);
+                               if (result) {
+                                       ERR("error while trying to get sock path for PID %u\n", (unsigned int) *pidit);
+                                       break;
+                               }
+                               printf("the socket path is %s\n", tmp);
+                               free(tmp);
+                               break;
+
+                       case SET_SOCK_PATH:
+                               result = ustcmd_set_sock_path(opts.regex, *pidit);
+                               if (result) {
+                                       ERR("error while trying to set sock path for PID %u\n", (unsigned int) *pidit);
+                               }
+                               break;
+
+                       case FORCE_SWITCH:
+                               result = ustcmd_force_switch(*pidit);
+                               if (result) {
+                                       ERR("error while trying to force switch for PID %u\n", (unsigned int) *pidit);
+                               }
+                               break;
+
                        default:
                                ERR("unknown command\n");
                        break;
This page took 0.024634 seconds and 4 git commands to generate.