15 char *progname
= NULL
;
19 fprintf(stderr
, "usage: %s [OPTIONS] COMMAND PID...\n", progname
);
20 fprintf(stderr
, "\nControl the tracing of a process that supports LTTng Userspace Tracing.\n\
23 --start-trace\t\t\tStart tracing\n\
24 --stop-trace\t\t\tStop tracing\n\
25 --destroy-trace\t\t\tDestroy the trace\n\
26 --enable-marker CHANNEL/MARKER\tEnable a marker\n\
27 --disable-marker CHANNEL/MARKER\tDisable a marker\n\
28 --list-markers\tList the markers of the process and their state\n\
33 int parse_opts_long(int argc
, char **argv
, struct ust_opts
*opts
)
43 int this_option_optind
= optind
? optind
: 1;
45 static struct option long_options
[] = {
46 {"start-trace", 0, 0, 1000},
47 {"stop-trace", 0, 0, 1001},
48 {"destroy-trace", 0, 0, 1002},
49 {"list-markers", 0, 0, 1004},
50 {"print-markers", 0, 0, 1005},
52 {"enable-marker", 1, 0, 1007},
53 {"disable-marker", 1, 0, 1008},
54 {"start", 0, 0, 1009},
56 {"version", 0, 0, 1010},
60 c
= getopt_long(argc
, argv
, "h", long_options
, &option_index
);
66 printf("option %s", long_options
[option_index
].name
);
68 printf(" with arg %s", optarg
);
73 opts
->cmd
= strdup("trace_start");
76 opts
->cmd
= strdup("trace_stop");
79 opts
->cmd
= strdup("start");
82 opts
->cmd
= strdup("trace_destroy");
85 opts
->cmd
= strdup("list_markers");
89 asprintf(&opts
->cmd
, "enable_marker %s", optarg
);
92 asprintf(&opts
->cmd
, "disable_marker %s", optarg
);
98 printf("Version 0\n");
101 /* unknown option or other error; error is printed by getopt, just return */
106 if(argc
- optind
> 0) {
109 opts
->pids
= malloc((argc
-optind
+1) * sizeof(pid_t
));
111 for(i
=optind
; i
<argc
; i
++) {
112 opts
->pids
[pididx
++] = atoi(argv
[i
]);
114 opts
->pids
[pididx
] = -1;
120 int main(int argc
, char *argv
[])
123 //char *msg = argv[2];
124 struct ustcomm_connection conn
;
126 struct ust_opts opts
;
131 fprintf(stderr
, "No operation specified.\n");
136 result
= parse_opts_long(argc
, argv
, &opts
);
142 if(opts
.pids
== NULL
) {
143 fprintf(stderr
, "No pid specified.\n");
147 if(opts
.cmd
== NULL
) {
148 fprintf(stderr
, "No command specified.\n");
155 while(*pidit
!= -1) {
164 result
= ustcomm_connect_app(*pidit
, &conn
);
166 fprintf(stderr
, "error connecting to process\n");
169 ustcomm_send_request(&conn
, opts
.cmd
, preply
);
This page took 0.044629 seconds and 4 git commands to generate.