option to see subbuffer size and count
authorDouglas Santos <douglas.santos@polymtl.ca>
Thu, 4 Mar 2010 18:30:54 +0000 (13:30 -0500)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Fri, 5 Mar 2010 21:25:14 +0000 (16:25 -0500)
libustcmd/ustcmd.c
libustcmd/ustcmd.h
ustctl/ustctl.c

index 7a05afa20079944b0ce3e79e60efcf06cc17f233..c2a98459ce6fb069730966a441da0cafee6d87f7 100644 (file)
@@ -150,6 +150,61 @@ int ustcmd_set_subbuf_num(const char *channel_size, pid_t pid)
        return 0;
 }
 
+/**
+ * Get subbuffer size.
+ *
+ * @param channel      Channel name
+ * @param pid          Traced process ID
+ * @return             subbuf size if successful, or error
+ */
+int ustcmd_get_subbuf_size(const char *channel, pid_t pid)
+{
+       char *cmd, *reply;
+       int result;
+
+       /* format: channel_cpu */
+       asprintf(&cmd, "%s %s_0", "get_subbuf_size", channel);
+
+       result = ustcmd_send_cmd(cmd, pid, &reply);
+       if (result) {
+               free(cmd);
+               free(reply);
+               return -1;
+       }
+
+       result = atoi(reply);
+       free(cmd);
+       free(reply);
+       return result;
+}
+
+/**
+ * Get subbuffer num.
+ *
+ * @param channel      Channel name
+ * @param pid          Traced process ID
+ * @return             subbuf cnf if successful, or error
+ */
+int ustcmd_get_subbuf_num(const char *channel, pid_t pid)
+{
+       char *cmd, *reply;
+       int result;
+
+       /* format: channel_cpu */
+       asprintf(&cmd, "%s %s_0", "get_n_subbufs", channel);
+
+       result = ustcmd_send_cmd(cmd, pid, &reply);
+       if (result) {
+               free(cmd);
+               free(reply);
+               return -1;
+       }
+
+       result = atoi(reply);
+       free(cmd);
+       free(reply);
+       return result;
+}
 
 /**
  * Destroys an UST trace according to a PID.
index ea918d59836615246011740f1e3e6e8def787dce..750d4133fec3563c9a79dfb11971618306b48846 100644 (file)
@@ -33,6 +33,8 @@ extern pid_t *ustcmd_get_online_pids(void);
 extern int ustcmd_set_marker_state(const char *, int, pid_t);
 extern int ustcmd_set_subbuf_size(const char *, pid_t);
 extern int ustcmd_set_subbuf_num(const char *, pid_t);
+extern int ustcmd_get_subbuf_size(const char *, pid_t);
+extern int ustcmd_get_subbuf_num(const char *, pid_t);
 extern int ustcmd_destroy_trace(pid_t);
 extern int ustcmd_setup_and_start(pid_t);
 extern int ustcmd_stop_trace(pid_t);
index ae7e318a1907e800d13dc9ca89c3b87c961cca3b..822ef4c9f505b3be009856510bf4972b52457c96 100644 (file)
@@ -38,6 +38,8 @@ enum command {
        GET_ONLINE_PIDS,
        SET_SUBBUF_SIZE,
        SET_SUBBUF_NUM,
+       GET_SUBBUF_SIZE,
+       GET_SUBBUF_NUM,
        UNKNOWN
 };
 
@@ -62,6 +64,8 @@ Commands:\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\
+    --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\
     --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\
@@ -91,6 +95,8 @@ 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 },
                        { 0, 0, 0, 0 }
                };
 
@@ -113,6 +119,8 @@ 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:
                        opts->regex = strdup(optarg);
                        break;
 
@@ -271,6 +279,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) {
This page took 0.026008 seconds and 4 git commands to generate.