projects
/
lttng-ust.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Re-write ustcomm parts of UST v2
[lttng-ust.git]
/
ustctl
/
ustctl.c
diff --git
a/ustctl/ustctl.c
b/ustctl/ustctl.c
index 0e8e01d236de2eec52231bdd8c63f7dd594b6bd6..bf149d11f8b6b4c666467f91505d5686783d3076 100644
(file)
--- a/
ustctl/ustctl.c
+++ b/
ustctl/ustctl.c
@@
-22,8
+22,7
@@
#include <stdlib.h>
#include <fcntl.h>
#include <stdlib.h>
#include <fcntl.h>
-#include "ustcomm.h"
-#include "ustcmd.h"
+#include "ust/ustcmd.h"
#include "usterr.h"
enum command {
#include "usterr.h"
enum command {
@@
-33,11
+32,17
@@
enum command {
STOP_TRACE,
DESTROY_TRACE,
LIST_MARKERS,
STOP_TRACE,
DESTROY_TRACE,
LIST_MARKERS,
+ LIST_TRACE_EVENTS,
ENABLE_MARKER,
DISABLE_MARKER,
GET_ONLINE_PIDS,
SET_SUBBUF_SIZE,
SET_SUBBUF_NUM,
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
};
UNKNOWN
};
@@
-56,14
+61,21
@@
void usage(void)
\n\
Commands:\n\
--create-trace\t\t\tCreate trace\n\
\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\
--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\
--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\
+ --list-trace-events\t\t\tList the trace-events of the process\n\
+ --force-switch\t\t\tForce a subbuffer switch\n\
\
");
}
\
");
}
@@
-84,12
+96,18
@@
int parse_opts_long(int argc, char **argv, struct ust_opts *opts)
{ "stop-trace", 0, 0, STOP_TRACE },
{ "destroy-trace", 0, 0, DESTROY_TRACE },
{ "list-markers", 0, 0, LIST_MARKERS },
{ "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", 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 },
{ "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 }
};
{ 0, 0, 0, 0 }
};
@@
-112,6
+130,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 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;
opts->regex = strdup(optarg);
break;
@@
-129,7
+150,7
@@
int parse_opts_long(int argc, char **argv, struct ust_opts *opts)
if (argc - optind > 0 && opts->cmd != GET_ONLINE_PIDS) {
int i;
int pididx=0;
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 =
z
malloc((argc-optind+1) * sizeof(pid_t));
for(i=optind; i<argc; i++) {
/* don't take any chances, use a long long */
for(i=optind; i<argc; i++) {
/* don't take any chances, use a long long */
@@
-152,6
+173,8
@@
int main(int argc, char *argv[])
{
pid_t *pidit;
int result;
{
pid_t *pidit;
int result;
+ int retval = EXIT_SUCCESS;
+ char *tmp;
struct ust_opts opts;
progname = argv[0];
struct ust_opts opts;
progname = argv[0];
@@
-196,6
+219,8
@@
int main(int argc, char *argv[])
pidit = opts.pids;
struct marker_status *cmsf = NULL;
pidit = opts.pids;
struct marker_status *cmsf = NULL;
+ struct trace_event_status *tes = NULL;
+ unsigned int i = 0;
while(*pidit != -1) {
switch (opts.cmd) {
while(*pidit != -1) {
switch (opts.cmd) {
@@
-203,6
+228,7
@@
int main(int argc, char *argv[])
result = ustcmd_create_trace(*pidit);
if (result) {
ERR("error while trying to create trace with PID %u\n", (unsigned int) *pidit);
result = ustcmd_create_trace(*pidit);
if (result) {
ERR("error while trying to create trace with PID %u\n", (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
break;
}
break;
break;
}
break;
@@
-211,6
+237,7
@@
int main(int argc, char *argv[])
result = ustcmd_start_trace(*pidit);
if (result) {
ERR("error while trying to for trace with PID %u\n", (unsigned int) *pidit);
result = ustcmd_start_trace(*pidit);
if (result) {
ERR("error while trying to for trace with PID %u\n", (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
break;
}
break;
break;
}
break;
@@
-219,6
+246,7
@@
int main(int argc, char *argv[])
result = ustcmd_stop_trace(*pidit);
if (result) {
ERR("error while trying to stop trace for PID %u\n", (unsigned int) *pidit);
result = ustcmd_stop_trace(*pidit);
if (result) {
ERR("error while trying to stop trace for PID %u\n", (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
break;
}
break;
break;
}
break;
@@
-227,6
+255,7
@@
int main(int argc, char *argv[])
result = ustcmd_destroy_trace(*pidit);
if (result) {
ERR("error while trying to destroy trace with PID %u\n", (unsigned int) *pidit);
result = ustcmd_destroy_trace(*pidit);
if (result) {
ERR("error while trying to destroy trace with PID %u\n", (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
break;
}
break;
break;
}
break;
@@
-234,12
+263,11
@@
int main(int argc, char *argv[])
case LIST_MARKERS:
cmsf = NULL;
if (ustcmd_get_cmsf(&cmsf, *pidit)) {
case LIST_MARKERS:
cmsf = NULL;
if (ustcmd_get_cmsf(&cmsf, *pidit)) {
- fprintf(stderr,
- "error while trying to list markers for"
- " PID %u\n", (unsigned int) *pidit);
+ ERR("error while trying to list markers for PID %u\n", (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
break;
}
break;
}
-
unsigned int
i = 0;
+ i = 0;
while (cmsf[i].channel != NULL) {
printf("{PID: %u, channel/marker: %s/%s, "
"state: %u, fmt: %s}\n",
while (cmsf[i].channel != NULL) {
printf("{PID: %u, channel/marker: %s/%s, "
"state: %u, fmt: %s}\n",
@@
-253,34
+281,124
@@
int main(int argc, char *argv[])
ustcmd_free_cmsf(cmsf);
break;
ustcmd_free_cmsf(cmsf);
break;
+ case LIST_TRACE_EVENTS:
+ tes = NULL;
+ if (ustcmd_get_tes(&tes, *pidit)) {
+ ERR("error while trying to list "
+ "trace_events for PID %u\n",
+ (unsigned int) *pidit);
+ break;
+ }
+ i = 0;
+ while (tes[i].name != NULL) {
+ printf("{PID: %u, trace_event: %s}\n",
+ (unsigned int) *pidit,
+ tes[i].name);
+ ++i;
+ }
+ ustcmd_free_tes(tes);
+
+ break;
case ENABLE_MARKER:
case ENABLE_MARKER:
- if(opts.regex)
- ustcmd_set_marker_state(opts.regex, 1, *pidit);
+ if (opts.regex) {
+ if (ustcmd_set_marker_state(opts.regex, 1, *pidit)) {
+ ERR("error while trying to enable marker %s with PID %u\n",
+ opts.regex, (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
+ }
+ }
break;
case DISABLE_MARKER:
break;
case DISABLE_MARKER:
- if(opts.regex)
- ustcmd_set_marker_state(opts.regex, 0, *pidit);
+ if (opts.regex) {
+ if (ustcmd_set_marker_state(opts.regex, 0, *pidit)) {
+ ERR("error while trying to disable marker %s with PID %u\n",
+ opts.regex, (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
+ }
+ }
break;
case SET_SUBBUF_SIZE:
break;
case SET_SUBBUF_SIZE:
- ustcmd_set_subbuf_size(opts.regex, *pidit);
+ if (opts.regex) {
+ if (ustcmd_set_subbuf_size(opts.regex, *pidit)) {
+ ERR("error while trying to set the size of subbuffers with PID %u\n",
+ (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
+ }
+ }
break;
case SET_SUBBUF_NUM:
break;
case SET_SUBBUF_NUM:
- ustcmd_set_subbuf_num(opts.regex, *pidit);
+ if (opts.regex) {
+ if (ustcmd_set_subbuf_num(opts.regex, *pidit)) {
+ ERR("error while trying to set the number of subbuffers with PID %u\n",
+ (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
+ }
+ }
+ 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);
+ retval = EXIT_FAILURE;
+ 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);
+ retval = EXIT_FAILURE;
+ break;
+ }
+
+ printf("the number of subbufers is %d\n", result);
break;
case ALLOC_TRACE:
result = ustcmd_alloc_trace(*pidit);
if (result) {
ERR("error while trying to alloc trace with PID %u\n", (unsigned int) *pidit);
break;
case ALLOC_TRACE:
result = ustcmd_alloc_trace(*pidit);
if (result) {
ERR("error while trying to alloc trace with PID %u\n", (unsigned int) *pidit);
+ retval = EXIT_FAILURE;
+ }
+ 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);
+ retval = EXIT_FAILURE;
break;
}
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);
+ retval = EXIT_FAILURE;
+ }
+ 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);
+ retval = EXIT_FAILURE;
+ }
break;
default:
ERR("unknown command\n");
break;
default:
ERR("unknown command\n");
- break;
+ retval = EXIT_FAILURE;
+ break;
}
pidit++;
}
pidit++;
@@
-293,6
+411,6
@@
int main(int argc, char *argv[])
free(opts.regex);
}
free(opts.regex);
}
- return
0
;
+ return
retval
;
}
}
This page took
0.027608 seconds
and
4
git commands to generate.