X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=ustctl%2Ftrace_cmds.c;fp=ustctl%2Ftrace_cmds.c;h=f6e11a7d4f437cbef630bc16cccf6045a2a0441a;hb=0c89df6cb75f1d967003137e7fc334af1128a42f;hp=0000000000000000000000000000000000000000;hpb=91594b712729c0d855efeab849c2093706336941;p=ust.git diff --git a/ustctl/trace_cmds.c b/ustctl/trace_cmds.c new file mode 100644 index 0000000..f6e11a7 --- /dev/null +++ b/ustctl/trace_cmds.c @@ -0,0 +1,162 @@ +/* Copyright (C) 2011 Ericsson AB, Nils Carlson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include +#include +#include +#include +#include "scanning_functions.h" +#include "usterr.h" +#include "cli.h" + + +static int create_trace(int argc, char *argv[]) +{ + pid_t pid; + + pid = parse_pid(argv[1]); + + if (ustcmd_create_trace(argv[2], pid)) { + ERR("Failed to create trace %s for PID %u\n", argv[2], pid); + return -1; + } + + return 0; +} + +static int alloc_trace(int argc, char *argv[]) +{ + pid_t pid; + + pid = parse_pid(argv[1]); + + if (ustcmd_alloc_trace(argv[2], pid)) { + ERR("Failed to allocate trace %s for PID %u\n", argv[2], pid); + return -1; + } + return 0; +} + +static int start_trace(int argc, char *argv[]) +{ + pid_t pid; + + pid = parse_pid(argv[1]); + + if (ustcmd_start_trace(argv[2], pid)) { + ERR("Failed to start trace %s for PID %u\n", argv[2], pid); + return -1; + } + return 0; +} + +static int stop_trace(int argc, char *argv[]) +{ + pid_t pid; + + pid = parse_pid(argv[1]); + + if (ustcmd_stop_trace(argv[2], pid)) { + ERR("Failed to stop trace %s for PID %u\n", argv[2], pid); + return -1; + } + return 0; +} + +static int destroy_trace(int argc, char *argv[]) +{ + pid_t pid; + + pid = parse_pid(argv[1]); + + if (ustcmd_destroy_trace(argv[2], pid)) { + ERR("Failed to destroy trace %s for PID %u\n", argv[2], pid); + return -1; + } + return 0; +} + +static int force_subbuf_switch(int argc, char *argv[]) +{ + pid_t pid; + + pid = parse_pid(argv[1]); + + if (ustcmd_force_switch(pid)) { + ERR("error while trying to force switch for PID %u\n", pid); + return -1; + } + + return 0; +} + +struct cli_cmd __cli_cmds trace_cmds[] = { + { + .name = "create-trace", + .description = "Create a trace for a process", + .help_text = "create-trace \n" + "Create a trace for a process\n", + .function = create_trace, + .desired_args = 2, + .desired_args_op = CLI_EQ, + }, + { + .name = "alloc-trace", + .description = "Allocate a trace for a process", + .help_text = "alloc-trace \n" + "Allocate a trace for a process\n", + .function = alloc_trace, + .desired_args = 2, + .desired_args_op = CLI_EQ, + }, + { + .name = "start-trace", + .description = "Start a trace for a process", + .help_text = "start-trace \n" + "Start a trace for a process\n", + .function = start_trace, + .desired_args = 2, + .desired_args_op = CLI_EQ, + }, + { + .name = "stop-trace", + .description = "Stop a trace for a process", + .help_text = "stop-trace \n" + "Stop a trace for a process\n", + .function = stop_trace, + .desired_args = 2, + .desired_args_op = CLI_EQ, + }, + { + .name = "destroy-trace", + .description = "Destroy a trace for a process", + .help_text = "destroy-trace \n" + "Destroy a trace for a process\n", + .function = destroy_trace, + .desired_args = 2, + .desired_args_op = CLI_EQ, + }, + { + .name = "force-subbuf-switch", + .description = "Force a subbuffer switch", + .help_text = "force-subbuf-switch \n" + "Force a subbuffer switch for a trace, currently this forces\n" + "a subbuffer switch for all traces in a process\n", + .function = force_subbuf_switch, + .desired_args = 2, + .desired_args_op = CLI_EQ, + }, +};