GDB (xrefs)
Loading...
Searching...
No Matches
mi-cmd-target.c
Go to the documentation of this file.
1/* MI Command Set - target commands.
2 Copyright (C) 2007-2023 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18
19#include "defs.h"
20#include "mi-cmds.h"
21#include "mi-getopt.h"
22#include "remote.h"
23
24/* Get a file from the target. */
25
26void
27mi_cmd_target_file_get (const char *command, const char *const *argv, int argc)
28{
29 int oind = 0;
30 const char *oarg;
31 const char *remote_file, *local_file;
32 static const struct mi_opt opts[] =
33 {
34 { 0, 0, 0 }
35 };
36 static const char prefix[] = "-target-file-get";
37
38 if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1
39 || oind != argc - 2)
40 error (_("-target-file-get: Usage: REMOTE_FILE LOCAL_FILE"));
41
42 remote_file = argv[oind];
43 local_file = argv[oind + 1];
44
45 remote_file_get (remote_file, local_file, 0);
46}
47
48/* Send a file to the target. */
49
50void
51mi_cmd_target_file_put (const char *command, const char *const *argv, int argc)
52{
53 int oind = 0;
54 const char *oarg;
55 const char *remote_file, *local_file;
56 static const struct mi_opt opts[] =
57 {
58 { 0, 0, 0 }
59 };
60 static const char prefix[] = "-target-file-put";
61
62 if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1
63 || oind != argc - 2)
64 error (_("-target-file-put: Usage: LOCAL_FILE REMOTE_FILE"));
65
66 local_file = argv[oind];
67 remote_file = argv[oind + 1];
68
69 remote_file_put (local_file, remote_file, 0);
70}
71
72/* Delete a file on the target. */
73
74void
75mi_cmd_target_file_delete (const char *command, const char *const *argv,
76 int argc)
77{
78 int oind = 0;
79 const char *oarg;
80 const char *remote_file;
81 static const struct mi_opt opts[] =
82 {
83 { 0, 0, 0 }
84 };
85 static const char prefix[] = "-target-file-delete";
86
87 if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1
88 || oind != argc - 1)
89 error (_("-target-file-delete: Usage: REMOTE_FILE"));
90
91 remote_file = argv[oind];
92
93 remote_file_delete (remote_file, 0);
94}
95
mi_cmd_argv_ftype mi_cmd_target_file_delete
mi_cmd_argv_ftype mi_cmd_target_file_get
mi_cmd_argv_ftype mi_cmd_target_file_put
int mi_getopt(const char *prefix, int argc, const char *const *argv, const struct mi_opt *opts, int *oind, const char **oarg)
Definition mi-getopt.c:82
#define prefix(a, b, R, do)
Definition ppc64-tdep.c:52
void remote_file_delete(const char *remote_file, int from_tty)
Definition remote.c:13054
void remote_file_put(const char *local_file, const char *remote_file, int from_tty)
Definition remote.c:12901
void remote_file_get(const char *remote_file, const char *local_file, int from_tty)
Definition remote.c:12994