GDB (xrefs)
Loading...
Searching...
No Matches
agent.c
Go to the documentation of this file.
1/* Copyright (C) 2012-2023 Free Software Foundation, Inc.
2
3 This file is part of GDB.
4
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.
9
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.
14
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/>. */
17
18#include "defs.h"
19#include "command.h"
20#include "gdbcmd.h"
21#include "target.h"
22#include "gdbsupport/agent.h"
23#include "observable.h"
24#include "objfiles.h"
25
26/* Enum strings for "set|show agent". */
27
28static const char can_use_agent_on[] = "on";
29static const char can_use_agent_off[] = "off";
30static const char * const can_use_agent_enum[] =
31{
34 NULL,
35};
36
37static const char *can_use_agent = can_use_agent_off;
38
39static void
40show_can_use_agent (struct ui_file *file, int from_tty,
41 struct cmd_list_element *c, const char *value)
42{
43 gdb_printf (file,
44 _("Debugger's willingness to use agent in inferior "
45 "as a helper is %s.\n"), value);
46}
47
48static void
49set_can_use_agent (const char *args, int from_tty, struct cmd_list_element *c)
50{
51 bool can_use = (can_use_agent == can_use_agent_on);
52 if (can_use && !agent_loaded_p ())
53 {
54 /* Since the setting was off, we may not have observed the objfiles and
55 therefore not looked up the required symbols. Do so now. */
57 if (agent_look_up_symbols (objfile) == 0)
58 break;
59 }
60 if (target_use_agent (can_use) == 0)
61 /* Something wrong during setting, set flag to default value. */
63}
64
65static void
67{
68 if (agent_loaded_p ())
69 return;
70
72 return;
73
74 agent_look_up_symbols (objfile);
75}
76
77void _initialize_agent ();
78void
80{
82 "agent");
83
86 &can_use_agent, _("\
87Set debugger's willingness to use agent as a helper."), _("\
88Show debugger's willingness to use agent as a helper."), _("\
89If on, GDB will delegate some of the debugging operations to the\n\
90agent, if the target supports it. This will speed up those\n\
91operations that are supported by the agent.\n\
92If off, GDB will not use agent, even if such is supported by the\n\
93target."),
96 &setlist, &showlist);
97}
static const char can_use_agent_off[]
Definition agent.c:29
void _initialize_agent()
Definition agent.c:79
static const char *const can_use_agent_enum[]
Definition agent.c:30
static void show_can_use_agent(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)
Definition agent.c:40
static void set_can_use_agent(const char *args, int from_tty, struct cmd_list_element *c)
Definition agent.c:49
static const char can_use_agent_on[]
Definition agent.c:28
static const char * can_use_agent
Definition agent.c:37
static void agent_new_objfile(struct objfile *objfile)
Definition agent.c:66
struct cmd_list_element * showlist
Definition cli-cmds.c:127
struct cmd_list_element * setlist
Definition cli-cmds.c:119
set_show_commands add_setshow_enum_cmd(const char *name, enum command_class theclass, const char *const *enumlist, const char **var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
Definition cli-decode.c:688
@ class_run
Definition command.h:54
observable< struct objfile * > new_objfile
struct program_space * current_program_space
Definition progspace.c:40
objfiles_range objfiles()
Definition progspace.h:209
Definition value.h:130
bool target_use_agent(bool use)
Definition target.c:797
void gdb_printf(struct ui_file *stream, const char *format,...)
Definition utils.c:1886