2013-03-12 Sebastian Huber <sebastian.huber@embedded-brains.de>
[binutils-gdb.git] / gdb / agent.c
blob63a0f327f744f2118bd65836084b49a5f04d843c
1 /* Copyright (C) 2012-2013 Free Software Foundation, Inc.
3 This file is part of GDB.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 #include "defs.h"
19 #include "command.h"
20 #include "gdbcmd.h"
21 #include "target.h"
22 #include "agent.h"
24 /* Enum strings for "set|show agent". */
26 static const char can_use_agent_on[] = "on";
27 static const char can_use_agent_off[] = "off";
28 static const char *can_use_agent_enum[] =
30 can_use_agent_on,
31 can_use_agent_off,
32 NULL,
35 static const char *can_use_agent = can_use_agent_off;
37 static void
38 show_can_use_agent (struct ui_file *file, int from_tty,
39 struct cmd_list_element *c, const char *value)
41 fprintf_filtered (file,
42 _("Debugger's willingness to use agent in inferior "
43 "as a helper is %s.\n"), value);
46 static void
47 set_can_use_agent (char *args, int from_tty, struct cmd_list_element *c)
49 if (target_use_agent (can_use_agent == can_use_agent_on) == 0)
50 /* Something wrong during setting, set flag to default value. */
51 can_use_agent = can_use_agent_off;
54 /* -Wmissing-prototypes */
55 extern initialize_file_ftype _initialize_agent;
57 #include "observer.h"
58 #include "objfiles.h"
60 static void
61 agent_new_objfile (struct objfile *objfile)
63 if (objfile == NULL || agent_loaded_p ())
64 return;
66 agent_look_up_symbols (objfile);
69 void
70 _initialize_agent (void)
72 observer_attach_new_objfile (agent_new_objfile);
74 add_setshow_enum_cmd ("agent", class_run,
75 can_use_agent_enum,
76 &can_use_agent, _("\
77 Set debugger's willingness to use agent as a helper."), _("\
78 Show debugger's willingness to use agent as a helper."), _("\
79 If on, GDB will delegate some of the debugging operations to the\n\
80 agent, if the target supports it. This will speed up those\n\
81 operations that are supported by the agent.\n\
82 If off, GDB will not use agent, even if such is supported by the\n\
83 target."),
84 set_can_use_agent,
85 show_can_use_agent,
86 &setlist, &showlist);