16 char *progname
= NULL
;
20 fprintf(stderr
, "usage: %s [OPTIONS] COMMAND PID...\n", progname
);
21 fprintf(stderr
, "\nControl the tracing of a process that supports LTTng Userspace Tracing.\n\
24 --start-trace\t\t\tStart tracing\n\
25 --stop-trace\t\t\tStop tracing\n\
26 --destroy-trace\t\t\tDestroy the trace\n\
27 --enable-marker CHANNEL/MARKER\tEnable a marker\n\
28 --disable-marker CHANNEL/MARKER\tDisable a marker\n\
29 --list-markers\tList the markers of the process and their state\n\
34 int parse_opts_long(int argc
, char **argv
, struct ust_opts
*opts
)
44 static struct option long_options
[] = {
45 {"start-trace", 0, 0, 1000},
46 {"stop-trace", 0, 0, 1001},
47 {"destroy-trace", 0, 0, 1002},
48 {"list-markers", 0, 0, 1004},
49 {"print-markers", 0, 0, 1005},
51 {"enable-marker", 1, 0, 1007},
52 {"disable-marker", 1, 0, 1008},
53 {"start", 0, 0, 1009},
55 {"version", 0, 0, 1010},
59 c
= getopt_long(argc
, argv
, "h", long_options
, &option_index
);
65 printf("option %s", long_options
[option_index
].name
);
67 printf(" with arg %s", optarg
);
72 opts
->cmd
= strdup("trace_start");
75 opts
->cmd
= strdup("trace_stop");
78 opts
->cmd
= strdup("start");
81 opts
->cmd
= strdup("trace_destroy");
84 opts
->cmd
= strdup("list_markers");
88 asprintf(&opts
->cmd
, "enable_marker %s", optarg
);
91 asprintf(&opts
->cmd
, "disable_marker %s", optarg
);
97 printf("Version 0\n");
100 /* unknown option or other error; error is printed by getopt, just return */
105 if(argc
- optind
> 0) {
108 opts
->pids
= malloc((argc
-optind
+1) * sizeof(pid_t
));
110 for(i
=optind
; i
<argc
; i
++) {
111 opts
->pids
[pididx
++] = atoi(argv
[i
]);
113 opts
->pids
[pididx
] = -1;
119 int main(int argc
, char *argv
[])
122 //char *msg = argv[2];
123 struct ustcomm_connection conn
;
125 struct ust_opts opts
;
130 fprintf(stderr
, "No operation specified.\n");
135 result
= parse_opts_long(argc
, argv
, &opts
);
141 if(opts
.pids
== NULL
) {
142 fprintf(stderr
, "No pid specified.\n");
146 if(opts
.cmd
== NULL
) {
147 fprintf(stderr
, "No command specified.\n");
154 while(*pidit
!= -1) {
163 result
= ustcomm_connect_app(*pidit
, &conn
);
165 fprintf(stderr
, "error connecting to process\n");
168 ustcomm_send_request(&conn
, opts
.cmd
, preply
);
This page took 0.047695 seconds and 5 git commands to generate.