15 int parse_opts_long(int argc
, char **argv
, struct ust_opts
*opts
)
25 int this_option_optind
= optind
? optind
: 1;
27 static struct option long_options
[] = {
28 {"start-trace", 0, 0, 1000},
29 {"stop-trace", 0, 0, 1001},
30 {"destroy-trace", 0, 0, 1002},
31 {"list-markers", 0, 0, 1004},
32 {"print-markers", 0, 0, 1005},
34 {"enable-marker", 1, 0, 1007},
35 {"disable-marker", 1, 0, 1008},
36 {"start", 0, 0, 1009},
38 {"version", 0, 0, 1010},
42 c
= getopt_long(argc
, argv
, "h", long_options
, &option_index
);
48 printf("option %s", long_options
[option_index
].name
);
50 printf(" with arg %s", optarg
);
55 opts
->cmd
= strdup("trace_start");
58 opts
->cmd
= strdup("trace_stop");
61 opts
->cmd
= strdup("start");
64 opts
->cmd
= strdup("trace_destroy");
67 opts
->cmd
= strdup("list_markers");
71 asprintf(&opts
->cmd
, "enable_marker %s", optarg
);
74 asprintf(&opts
->cmd
, "disable_marker %s", optarg
);
80 printf("Version 0\n");
83 /* unknown option or other error; error is printed by getopt, just return */
88 if(argc
- optind
> 0) {
91 opts
->pids
= malloc((argc
-optind
+1) * sizeof(pid_t
));
93 for(i
=optind
; i
<argc
; i
++) {
94 opts
->pids
[pididx
++] = atoi(argv
[i
]);
96 opts
->pids
[pididx
] = -1;
102 char *progname
= NULL
;
106 fprintf(stderr
, "usage: %s [OPTIONS] COMMAND PID...\n", progname
);
107 fprintf(stderr
, "\nControl the tracing of a process that supports LTTng Userspace Tracing.\n\
110 --start-trace\t\t\tStart tracing\n\
111 --stop-trace\t\t\tStop tracing\n\
112 --destroy-trace\t\t\tDestroy the trace\n\
113 --enable-marker CHANNEL/MARKER\tEnable a marker\n\
114 --disable-marker CHANNEL/MARKER\tDisable a marker\n\
115 --list-markers\tList the markers of the process and their state\n\
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.040291 seconds and 4 git commands to generate.