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/ustcmd.h>
21 #include "scanning_functions.h"
25 static int list_markers(int argc
, char *argv
[])
27 struct marker_status
*cmsf
= NULL
;
31 pid
= parse_pid(argv
[1]);
33 if (ustcmd_get_cmsf(&cmsf
, pid
)) {
34 ERR("error while trying to list markers for PID %u\n", pid
);
37 for (i
= 0; cmsf
[i
].channel
; i
++) {
38 printf("{PID: %u, channel/marker: %s/%s, "
39 "state: %u, fmt: %s}\n",
46 ustcmd_free_cmsf(cmsf
);
50 static int enable_marker(int argc
, char *argv
[])
54 char *channel
, *marker
;
56 pid
= parse_pid(argv
[1]);
58 for (i
= 3; i
< argc
; i
++) {
61 if (scan_ch_marker(argv
[i
],
64 fprintf(stderr
, "Failed to scan channel and marker from"
71 if (ustcmd_set_marker_state(argv
[2], channel
, marker
, 1, pid
)) {
72 PERROR("error while trying to enable marker %s with PID %u",
83 static int disable_marker(int argc
, char *argv
[])
87 char *channel
, *marker
;
89 pid
= parse_pid(argv
[1]);
91 for (i
= 3; i
< argc
; i
++) {
94 if (scan_ch_marker(argv
[i
],
96 fprintf(stderr
, "Failed to scan channel and marker from"
104 if (ustcmd_set_marker_state(argv
[2], channel
, marker
, 0, pid
)) {
105 PERROR("error while trying to disable marker %s with PID %u",
116 struct cli_cmd __cli_cmds marker_cmds
[] = {
118 .name
= "list-markers",
119 .description
= "List markers for a given pid",
120 .help_text
= "list-markers <pid>\n"
121 "List the markers in a process\n",
122 .function
= list_markers
,
124 .desired_args_op
= CLI_EQ
,
127 .name
= "enable-marker",
128 .description
= "Enable markers for a given pid",
129 .help_text
= "enable-marker <pid> <trace> <channel>/<marker>... \n"
130 "Enable the listed markers for the trace in process pid\n",
131 .function
= enable_marker
,
133 .desired_args_op
= CLI_GE
,
136 .name
= "disable-marker",
137 .description
= "Disable markers for a given pid",
138 .help_text
= "disable-marker <pid> <trace> <channel>/<marker>... \n"
139 "Disable the listed markers for the trace in process pid\n",
140 .function
= disable_marker
,
142 .desired_args_op
= CLI_GE
,