gdb/mi/mi-cmd-target.c - gdb

Functions defined

Source code

  1. /* MI Command Set - target commands.
  2.    Copyright (C) 2007-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program 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
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. #include "defs.h"
  15. #include "mi-cmds.h"
  16. #include "mi-getopt.h"
  17. #include "remote.h"

  18. /* Get a file from the target.  */

  19. void
  20. mi_cmd_target_file_get (char *command, char **argv, int argc)
  21. {
  22.   int oind = 0;
  23.   char *oarg;
  24.   const char *remote_file, *local_file;
  25.   static const struct mi_opt opts[] =
  26.     {
  27.       { 0, 0, 0 }
  28.     };
  29.   static const char prefix[] = "-target-file-get";

  30.   if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1
  31.       || oind != argc - 2)
  32.     error (_("-target-file-get: Usage: REMOTE_FILE LOCAL_FILE"));

  33.   remote_file = argv[oind];
  34.   local_file = argv[oind + 1];

  35.   remote_file_get (remote_file, local_file, 0);
  36. }

  37. /* Send a file to the target.  */

  38. void
  39. mi_cmd_target_file_put (char *command, char **argv, int argc)
  40. {
  41.   int oind = 0;
  42.   char *oarg;
  43.   const char *remote_file, *local_file;
  44.   static const struct mi_opt opts[] =
  45.     {
  46.       { 0, 0, 0 }
  47.     };
  48.   static const char prefix[] = "-target-file-put";

  49.   if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1
  50.       || oind != argc - 2)
  51.     error (_("-target-file-put: Usage: LOCAL_FILE REMOTE_FILE"));

  52.   local_file = argv[oind];
  53.   remote_file = argv[oind + 1];

  54.   remote_file_put (local_file, remote_file, 0);
  55. }

  56. /* Delete a file on the target.  */

  57. void
  58. mi_cmd_target_file_delete (char *command, char **argv, int argc)
  59. {
  60.   int oind = 0;
  61.   char *oarg;
  62.   const char *remote_file;
  63.   static const struct mi_opt opts[] =
  64.     {
  65.       { 0, 0, 0 }
  66.     };
  67.   static const char prefix[] = "-target-file-delete";

  68.   if (mi_getopt (prefix, argc, argv, opts, &oind, &oarg) != -1
  69.       || oind != argc - 1)
  70.     error (_("-target-file-delete: Usage: REMOTE_FILE"));

  71.   remote_file = argv[oind];

  72.   remote_file_delete (remote_file, 0);
  73. }