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"
26 static int create_trace(int argc
, char *argv
[])
30 pid
= parse_pid(argv
[1]);
32 if (ustcmd_create_trace(argv
[2], pid
)) {
33 ERR("Failed to create trace %s for PID %u\n", argv
[2], pid
);
40 static int alloc_trace(int argc
, char *argv
[])
44 pid
= parse_pid(argv
[1]);
46 if (ustcmd_alloc_trace(argv
[2], pid
)) {
47 ERR("Failed to allocate trace %s for PID %u\n", argv
[2], pid
);
53 static int start_trace(int argc
, char *argv
[])
57 pid
= parse_pid(argv
[1]);
59 if (ustcmd_start_trace(argv
[2], pid
)) {
60 ERR("Failed to start trace %s for PID %u\n", argv
[2], pid
);
66 static int stop_trace(int argc
, char *argv
[])
70 pid
= parse_pid(argv
[1]);
72 if (ustcmd_stop_trace(argv
[2], pid
)) {
73 ERR("Failed to stop trace %s for PID %u\n", argv
[2], pid
);
79 static int destroy_trace(int argc
, char *argv
[])
83 pid
= parse_pid(argv
[1]);
85 if (ustcmd_destroy_trace(argv
[2], pid
)) {
86 ERR("Failed to destroy trace %s for PID %u\n", argv
[2], pid
);
92 static int force_subbuf_switch(int argc
, char *argv
[])
96 pid
= parse_pid(argv
[1]);
98 if (ustcmd_force_switch(pid
)) {
99 ERR("error while trying to force switch for PID %u\n", pid
);
106 struct cli_cmd __cli_cmds trace_cmds
[] = {
108 .name
= "create-trace",
109 .description
= "Create a trace for a process",
110 .help_text
= "create-trace <pid> <trace>\n"
111 "Create a trace for a process\n",
112 .function
= create_trace
,
114 .desired_args_op
= CLI_EQ
,
117 .name
= "alloc-trace",
118 .description
= "Allocate a trace for a process",
119 .help_text
= "alloc-trace <pid> <trace>\n"
120 "Allocate a trace for a process\n",
121 .function
= alloc_trace
,
123 .desired_args_op
= CLI_EQ
,
126 .name
= "start-trace",
127 .description
= "Start a trace for a process",
128 .help_text
= "start-trace <pid> <trace>\n"
129 "Start a trace for a process\n",
130 .function
= start_trace
,
132 .desired_args_op
= CLI_EQ
,
135 .name
= "stop-trace",
136 .description
= "Stop a trace for a process",
137 .help_text
= "stop-trace <pid> <trace>\n"
138 "Stop a trace for a process\n",
139 .function
= stop_trace
,
141 .desired_args_op
= CLI_EQ
,
144 .name
= "destroy-trace",
145 .description
= "Destroy a trace for a process",
146 .help_text
= "destroy-trace <pid> <trace>\n"
147 "Destroy a trace for a process\n",
148 .function
= destroy_trace
,
150 .desired_args_op
= CLI_EQ
,
153 .name
= "force-subbuf-switch",
154 .description
= "Force a subbuffer switch",
155 .help_text
= "force-subbuf-switch <pid> <trace>\n"
156 "Force a subbuffer switch for a trace, currently this forces\n"
157 "a subbuffer switch for all traces in a process\n",
158 .function
= force_subbuf_switch
,
160 .desired_args_op
= CLI_EQ
,