1 /* Copyright (C) 2011 Ericsson AB, Nils Carlson <nils.carlson@ericsson.com>
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
18 #include <sys/types.h>
20 #include <ust/ustctl.h>
21 #include "scanning_functions.h"
25 static int list_markers(int argc
, char *argv
[])
27 struct ust_marker_status
*cmsf
= NULL
;
30 sock
= parse_and_connect_pid(argv
[1]);
32 if (ustctl_get_cmsf(sock
, &cmsf
)) {
33 ERR("error while trying to list markers for PID %s\n", argv
[1]);
36 for (i
= 0; cmsf
[i
].channel
; i
++) {
37 printf("{PID: %s, channel/marker: %s/%s, "
38 "state: %u, fmt: %s}\n",
45 ustctl_free_cmsf(cmsf
);
49 static int enable_marker(int argc
, char *argv
[])
51 int i
, sock
, result
= 0;
52 char *channel
, *marker
;
54 sock
= parse_and_connect_pid(argv
[1]);
56 for (i
= 3; i
< argc
; i
++) {
59 if (scan_ch_marker(argv
[i
],
62 fprintf(stderr
, "Failed to scan channel and marker from"
69 if (ustctl_set_ust_marker_state(sock
, argv
[2], channel
, marker
, 1)) {
70 PERROR("error while trying to enable marker %s with PID %s",
81 static int disable_marker(int argc
, char *argv
[])
83 int i
, sock
, result
= 0;
84 char *channel
, *marker
;
86 sock
= parse_and_connect_pid(argv
[1]);
88 for (i
= 3; i
< argc
; i
++) {
91 if (scan_ch_marker(argv
[i
],
93 fprintf(stderr
, "Failed to scan channel and marker from"
101 if (ustctl_set_ust_marker_state(sock
, argv
[2], channel
, marker
, 0)) {
102 PERROR("error while trying to disable marker %s with PID %s",
113 struct cli_cmd __cli_cmds ust_marker_cmds
[] = {
115 .name
= "list-markers",
116 .description
= "List markers for a given pid",
117 .help_text
= "list-markers <pid>\n"
118 "List the markers in a process\n",
119 .function
= list_markers
,
121 .desired_args_op
= CLI_EQ
,
124 .name
= "enable-marker",
125 .description
= "Enable markers for a given pid",
126 .help_text
= "enable-marker <pid> <trace> <channel>/<marker>... \n"
127 "Enable the listed markers for the trace in process pid\n",
128 .function
= enable_marker
,
130 .desired_args_op
= CLI_GE
,
133 .name
= "disable-marker",
134 .description
= "Disable markers for a given pid",
135 .help_text
= "disable-marker <pid> <trace> <channel>/<marker>... \n"
136 "Disable the listed markers for the trace in process pid\n",
137 .function
= disable_marker
,
139 .desired_args_op
= CLI_GE
,