1 /* Copyright (C) 2009 Pierre-Marc Fournier
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 char *progname
= NULL
;
37 fprintf(stderr
, "usage: %s [OPTIONS] COMMAND PID...\n", progname
);
38 fprintf(stderr
, "\nControl the tracing of a process that supports LTTng Userspace Tracing.\n\
41 --start-trace\t\t\tStart tracing\n\
42 --stop-trace\t\t\tStop tracing\n\
43 --destroy-trace\t\t\tDestroy the trace\n\
44 --enable-marker CHANNEL/MARKER\tEnable a marker\n\
45 --disable-marker CHANNEL/MARKER\tDisable a marker\n\
46 --list-markers\tList the markers of the process and their state\n\
51 int parse_opts_long(int argc
, char **argv
, struct ust_opts
*opts
)
61 static struct option long_options
[] = {
62 {"start-trace", 0, 0, 1000},
63 {"stop-trace", 0, 0, 1001},
64 {"destroy-trace", 0, 0, 1002},
65 {"list-markers", 0, 0, 1004},
66 {"print-markers", 0, 0, 1005},
68 {"enable-marker", 1, 0, 1007},
69 {"disable-marker", 1, 0, 1008},
70 {"start", 0, 0, 1009},
72 {"version", 0, 0, 1010},
76 c
= getopt_long(argc
, argv
, "h", long_options
, &option_index
);
82 printf("option %s", long_options
[option_index
].name
);
84 printf(" with arg %s", optarg
);
89 opts
->cmd
= strdup("trace_start");
92 opts
->cmd
= strdup("trace_stop");
95 opts
->cmd
= strdup("start");
98 opts
->cmd
= strdup("trace_destroy");
101 opts
->cmd
= strdup("list_markers");
102 opts
->take_reply
= 1;
105 asprintf(&opts
->cmd
, "enable_marker %s", optarg
);
108 asprintf(&opts
->cmd
, "disable_marker %s", optarg
);
114 printf("Version 0\n");
117 /* unknown option or other error; error is printed by getopt, just return */
122 if(argc
- optind
> 0) {
125 opts
->pids
= malloc((argc
-optind
+1) * sizeof(pid_t
));
127 for(i
=optind
; i
<argc
; i
++) {
128 opts
->pids
[pididx
++] = atoi(argv
[i
]);
130 opts
->pids
[pididx
] = -1;
136 int main(int argc
, char *argv
[])
139 //char *msg = argv[2];
140 struct ustcomm_connection conn
;
142 struct ust_opts opts
;
147 fprintf(stderr
, "No operation specified.\n");
152 result
= parse_opts_long(argc
, argv
, &opts
);
158 if(opts
.pids
== NULL
) {
159 fprintf(stderr
, "No pid specified.\n");
163 if(opts
.cmd
== NULL
) {
164 fprintf(stderr
, "No command specified.\n");
171 while(*pidit
!= -1) {
180 result
= ustcomm_connect_app(*pidit
, &conn
);
182 fprintf(stderr
, "error connecting to process\n");
185 ustcomm_send_request(&conn
, opts
.cmd
, preply
);
This page took 0.033035 seconds and 4 git commands to generate.