xref: /dflybsd-src/contrib/gdb-7/gdb/mi/mi-cmd-target.c (revision de8e141f24382815c10a4012d209bbbf7abf1112)
15796c8dcSSimon Schubert /* MI Command Set - target commands.
2*ef5ccd6cSJohn Marino    Copyright (C) 2007-2013 Free Software Foundation, Inc.
35796c8dcSSimon Schubert 
45796c8dcSSimon Schubert    This file is part of GDB.
55796c8dcSSimon Schubert 
65796c8dcSSimon Schubert    This program is free software; you can redistribute it and/or modify
75796c8dcSSimon Schubert    it under the terms of the GNU General Public License as published by
85796c8dcSSimon Schubert    the Free Software Foundation; either version 3 of the License, or
95796c8dcSSimon Schubert    (at your option) any later version.
105796c8dcSSimon Schubert 
115796c8dcSSimon Schubert    This program is distributed in the hope that it will be useful,
125796c8dcSSimon Schubert    but WITHOUT ANY WARRANTY; without even the implied warranty of
135796c8dcSSimon Schubert    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
145796c8dcSSimon Schubert    GNU General Public License for more details.
155796c8dcSSimon Schubert 
165796c8dcSSimon Schubert    You should have received a copy of the GNU General Public License
175796c8dcSSimon Schubert    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
185796c8dcSSimon Schubert 
195796c8dcSSimon Schubert #include "defs.h"
205796c8dcSSimon Schubert #include "mi-cmds.h"
215796c8dcSSimon Schubert #include "mi-getopt.h"
225796c8dcSSimon Schubert #include "remote.h"
235796c8dcSSimon Schubert 
245796c8dcSSimon Schubert /* Get a file from the target.  */
255796c8dcSSimon Schubert 
265796c8dcSSimon Schubert void
mi_cmd_target_file_get(char * command,char ** argv,int argc)275796c8dcSSimon Schubert mi_cmd_target_file_get (char *command, char **argv, int argc)
285796c8dcSSimon Schubert {
29*ef5ccd6cSJohn Marino   int oind = 0;
30*ef5ccd6cSJohn Marino   char *oarg;
315796c8dcSSimon Schubert   const char *remote_file, *local_file;
32a45ae5f8SJohn Marino   static const struct mi_opt opts[] =
335796c8dcSSimon Schubert     {
345796c8dcSSimon Schubert       { 0, 0, 0 }
355796c8dcSSimon Schubert     };
36a45ae5f8SJohn Marino   static const char prefix[] = "-target-file-get";
375796c8dcSSimon Schubert 
38*ef5ccd6cSJohn Marino   if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1
39*ef5ccd6cSJohn Marino       || oind != argc - 2)
40c50c785cSJohn Marino     error (_("-target-file-get: Usage: REMOTE_FILE LOCAL_FILE"));
415796c8dcSSimon Schubert 
42*ef5ccd6cSJohn Marino   remote_file = argv[oind];
43*ef5ccd6cSJohn Marino   local_file = argv[oind + 1];
445796c8dcSSimon Schubert 
455796c8dcSSimon Schubert   remote_file_get (remote_file, local_file, 0);
465796c8dcSSimon Schubert }
475796c8dcSSimon Schubert 
485796c8dcSSimon Schubert /* Send a file to the target.  */
495796c8dcSSimon Schubert 
505796c8dcSSimon Schubert void
mi_cmd_target_file_put(char * command,char ** argv,int argc)515796c8dcSSimon Schubert mi_cmd_target_file_put (char *command, char **argv, int argc)
525796c8dcSSimon Schubert {
53*ef5ccd6cSJohn Marino   int oind = 0;
54*ef5ccd6cSJohn Marino   char *oarg;
555796c8dcSSimon Schubert   const char *remote_file, *local_file;
56a45ae5f8SJohn Marino   static const struct mi_opt opts[] =
575796c8dcSSimon Schubert     {
585796c8dcSSimon Schubert       { 0, 0, 0 }
595796c8dcSSimon Schubert     };
60a45ae5f8SJohn Marino   static const char prefix[] = "-target-file-put";
615796c8dcSSimon Schubert 
62*ef5ccd6cSJohn Marino   if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1
63*ef5ccd6cSJohn Marino       || oind != argc - 2)
64c50c785cSJohn Marino     error (_("-target-file-put: Usage: LOCAL_FILE REMOTE_FILE"));
655796c8dcSSimon Schubert 
66*ef5ccd6cSJohn Marino   local_file = argv[oind];
67*ef5ccd6cSJohn Marino   remote_file = argv[oind + 1];
685796c8dcSSimon Schubert 
695796c8dcSSimon Schubert   remote_file_put (local_file, remote_file, 0);
705796c8dcSSimon Schubert }
715796c8dcSSimon Schubert 
725796c8dcSSimon Schubert /* Delete a file on the target.  */
735796c8dcSSimon Schubert 
745796c8dcSSimon Schubert void
mi_cmd_target_file_delete(char * command,char ** argv,int argc)755796c8dcSSimon Schubert mi_cmd_target_file_delete (char *command, char **argv, int argc)
765796c8dcSSimon Schubert {
77*ef5ccd6cSJohn Marino   int oind = 0;
78*ef5ccd6cSJohn Marino   char *oarg;
79cf7f2e2dSJohn Marino   const char *remote_file;
80a45ae5f8SJohn Marino   static const struct mi_opt opts[] =
815796c8dcSSimon Schubert     {
825796c8dcSSimon Schubert       { 0, 0, 0 }
835796c8dcSSimon Schubert     };
84a45ae5f8SJohn Marino   static const char prefix[] = "-target-file-delete";
855796c8dcSSimon Schubert 
86*ef5ccd6cSJohn Marino   if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1
87*ef5ccd6cSJohn Marino       || oind != argc - 1)
88c50c785cSJohn Marino     error (_("-target-file-delete: Usage: REMOTE_FILE"));
895796c8dcSSimon Schubert 
90*ef5ccd6cSJohn Marino   remote_file = argv[oind];
915796c8dcSSimon Schubert 
925796c8dcSSimon Schubert   remote_file_delete (remote_file, 0);
935796c8dcSSimon Schubert }
945796c8dcSSimon Schubert 
95