b2f30f0a4c4d8f4ed912c9a2f34af2d07c843849
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 int this_option_optind
= optind
? optind
: 1;
46 static struct option long_options
[] = {
47 {"start-trace", 0, 0, 1000},
48 {"stop-trace", 0, 0, 1001},
49 {"destroy-trace", 0, 0, 1002},
50 {"list-markers", 0, 0, 1004},
51 {"print-markers", 0, 0, 1005},
53 {"enable-marker", 1, 0, 1007},
54 {"disable-marker", 1, 0, 1008},
55 {"start", 0, 0, 1009},
57 {"version", 0, 0, 1010},
61 c
= getopt_long(argc
, argv
, "h", long_options
, &option_index
);
67 printf("option %s", long_options
[option_index
].name
);
69 printf(" with arg %s", optarg
);
74 opts
->cmd
= strdup("trace_start");
77 opts
->cmd
= strdup("trace_stop");
80 opts
->cmd
= strdup("start");
83 opts
->cmd
= strdup("trace_destroy");
86 opts
->cmd
= strdup("list_markers");
90 asprintf(&opts
->cmd
, "enable_marker %s", optarg
);
93 asprintf(&opts
->cmd
, "disable_marker %s", optarg
);
99 printf("Version 0\n");
102 /* unknown option or other error; error is printed by getopt, just return */
107 if(argc
- optind
> 0) {
110 opts
->pids
= malloc((argc
-optind
+1) * sizeof(pid_t
));
112 for(i
=optind
; i
<argc
; i
++) {
113 opts
->pids
[pididx
++] = atoi(argv
[i
]);
115 opts
->pids
[pididx
] = -1;
121 int main(int argc
, char *argv
[])
124 //char *msg = argv[2];
125 struct ustcomm_connection conn
;
127 struct ust_opts opts
;
132 fprintf(stderr
, "No operation specified.\n");
137 result
= parse_opts_long(argc
, argv
, &opts
);
143 if(opts
.pids
== NULL
) {
144 fprintf(stderr
, "No pid specified.\n");
148 if(opts
.cmd
== NULL
) {
149 fprintf(stderr
, "No command specified.\n");
156 while(*pidit
!= -1) {
165 result
= ustcomm_connect_app(*pidit
, &conn
);
167 fprintf(stderr
, "error connecting to process\n");
170 ustcomm_send_request(&conn
, opts
.cmd
, preply
);
This page took 0.032442 seconds and 3 git commands to generate.