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