From: Douglas Santos Date: Thu, 4 Mar 2010 18:30:54 +0000 (-0500) Subject: option to see subbuffer size and count X-Git-Tag: v1.9.1~666 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=e77b8e8e6202b3a5ff87dc20553d2fad9ed5ff2e;p=lttng-ust.git option to see subbuffer size and count --- diff --git a/libustcmd/ustcmd.c b/libustcmd/ustcmd.c index 7a05afa2..c2a98459 100644 --- a/libustcmd/ustcmd.c +++ b/libustcmd/ustcmd.c @@ -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. diff --git a/libustcmd/ustcmd.h b/libustcmd/ustcmd.h index ea918d59..750d4133 100644 --- a/libustcmd/ustcmd.h +++ b/libustcmd/ustcmd.h @@ -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); diff --git a/ustctl/ustctl.c b/ustctl/ustctl.c index ae7e318a..822ef4c9 100644 --- a/ustctl/ustctl.c +++ b/ustctl/ustctl.c @@ -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) {