gdb/agent.c - gdb

Global variables defined

Functions defined

Source code

  1. /* Copyright (C) 2012-2015 Free Software Foundation, Inc.

  2.    This file is part of GDB.

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

  7.    This program is distributed in the hope that it will be useful,
  8.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  9.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  10.    GNU General Public License for more details.

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

  13. #include "defs.h"
  14. #include "command.h"
  15. #include "gdbcmd.h"
  16. #include "target.h"
  17. #include "agent.h"

  18. /* Enum strings for "set|show agent".  */

  19. static const char can_use_agent_on[] = "on";
  20. static const char can_use_agent_off[] = "off";
  21. static const char *can_use_agent_enum[] =
  22. {
  23.   can_use_agent_on,
  24.   can_use_agent_off,
  25.   NULL,
  26. };

  27. static const char *can_use_agent = can_use_agent_off;

  28. static void
  29. show_can_use_agent (struct ui_file *file, int from_tty,
  30.                     struct cmd_list_element *c, const char *value)
  31. {
  32.   fprintf_filtered (file,
  33.                     _("Debugger's willingness to use agent in inferior "
  34.                       "as a helper is %s.\n"), value);
  35. }

  36. static void
  37. set_can_use_agent (char *args, int from_tty, struct cmd_list_element *c)
  38. {
  39.   if (target_use_agent (can_use_agent == can_use_agent_on) == 0)
  40.     /* Something wrong during setting, set flag to default value.  */
  41.     can_use_agent = can_use_agent_off;
  42. }

  43. /* -Wmissing-prototypes */
  44. extern initialize_file_ftype _initialize_agent;

  45. #include "observer.h"
  46. #include "objfiles.h"

  47. static void
  48. agent_new_objfile (struct objfile *objfile)
  49. {
  50.   if (objfile == NULL || agent_loaded_p ())
  51.     return;

  52.   agent_look_up_symbols (objfile);
  53. }

  54. void
  55. _initialize_agent (void)
  56. {
  57.   observer_attach_new_objfile (agent_new_objfile);

  58.   add_setshow_enum_cmd ("agent", class_run,
  59.                         can_use_agent_enum,
  60.                         &can_use_agent, _("\
  61. Set debugger's willingness to use agent as a helper."), _("\
  62. Show debugger's willingness to use agent as a helper."), _("\
  63. If on, GDB will delegate some of the debugging operations to the\n\
  64. agent, if the target supports it.  This will speed up those\n\
  65. operations that are supported by the agent.\n\
  66. If off, GDB will not use agent, even if such is supported by the\n\
  67. target."),
  68.                         set_can_use_agent,
  69.                         show_can_use_agent,
  70.                         &setlist, &showlist);
  71. }