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"
26 static int create_trace(int argc
, char *argv
[])
30 sock
= parse_and_connect_pid(argv
[1]);
32 if (ustctl_create_trace(sock
, argv
[2])) {
33 ERR("Failed to create trace %s for PID %s\n", argv
[2], argv
[1]);
40 static int alloc_trace(int argc
, char *argv
[])
44 sock
= parse_and_connect_pid(argv
[1]);
46 if (ustctl_alloc_trace(sock
, argv
[2])) {
47 ERR("Failed to allocate trace %s for PID %s\n", argv
[2], argv
[1]);
53 static int start_trace(int argc
, char *argv
[])
57 sock
= parse_and_connect_pid(argv
[1]);
59 if (ustctl_start_trace(sock
, argv
[2])) {
60 ERR("Failed to start trace %s for PID %s\n", argv
[2], argv
[1]);
66 static int stop_trace(int argc
, char *argv
[])
70 sock
= parse_and_connect_pid(argv
[1]);
72 if (ustctl_stop_trace(sock
, argv
[2])) {
73 ERR("Failed to stop trace %s for PID %s\n", argv
[2], argv
[1]);
79 static int destroy_trace(int argc
, char *argv
[])
83 sock
= parse_and_connect_pid(argv
[1]);
85 if (ustctl_destroy_trace(sock
, argv
[2])) {
86 ERR("Failed to destroy trace %s for PID %s\n", argv
[2], argv
[1]);
92 static int force_subbuf_switch(int argc
, char *argv
[])
96 sock
= parse_and_connect_pid(argv
[1]);
98 if (ustctl_force_switch(sock
, argv
[2])) {
99 ERR("error while trying to force switch for PID %s\n", argv
[1]);
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
,