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},
40 c
= getopt_long(argc
, argv
, "", long_options
, &option_index
);
46 printf("option %s", long_options
[option_index
].name
);
48 printf(" with arg %s", optarg
);
53 opts
->cmd
= strdup("trace_start");
56 opts
->cmd
= strdup("trace_stop");
59 opts
->cmd
= strdup("start");
62 opts
->cmd
= strdup("trace_destroy");
65 opts
->cmd
= strdup("list_markers");
69 asprintf(&opts
->cmd
, "enable_marker %s", optarg
);
72 asprintf(&opts
->cmd
, "disable_marker %s", optarg
);
76 /* unknown option or other error; error is printed by getopt, just return */
81 if(argc
- optind
> 0) {
84 opts
->pids
= malloc((argc
-optind
+1) * sizeof(pid_t
));
86 for(i
=optind
; i
<argc
; i
++) {
87 opts
->pids
[pididx
++] = atoi(argv
[i
]);
89 opts
->pids
[pididx
] = -1;
95 char *progname
= NULL
;
99 fprintf(stderr
, "usage: %s [OPTIONS] OPERATION PID...\n", progname
);
100 fprintf(stderr
, "\nControl the tracing of a process that supports LTTng Userspace Tracing.\n\
103 \t--start-trace\tStart tracing\n\
104 \t--stop-trace\tStop tracing\n\
105 \t--destroy-trace\tDestroy the trace\n\
106 \t--enable-marker CHANNEL_NAME/MARKER_NAME\tEnable a marker\n\
107 \t--disable-marker CHANNEL_NAME/MARKER_NAME\tDisable a marker\n\
108 \t--list-markers\tList the markers of the process and their state\n\
113 int main(int argc
, char *argv
[])
116 //char *msg = argv[2];
117 struct ustcomm_connection conn
;
119 struct ust_opts opts
;
124 fprintf(stderr
, "No operation specified.\n");
129 result
= parse_opts_long(argc
, argv
, &opts
);
135 if(opts
.pids
== NULL
) {
136 fprintf(stderr
, "No pid specified.\n");
140 if(opts
.cmd
== NULL
) {
141 fprintf(stderr
, "No command specified.\n");
148 while(*pidit
!= -1) {
157 result
= ustcomm_connect_app(*pidit
, &conn
);
159 fprintf(stderr
, "error connecting to process\n");
162 ustcomm_send_request(&conn
, opts
.cmd
, preply
);
This page took 0.032302 seconds and 4 git commands to generate.