aboutsummaryrefslogtreecommitdiff
path: root/gdb/agent.c
diff options
context:
space:
mode:
authorChristian Biesinger <cbiesinger@google.com>2019-10-30 19:10:13 -0500
committerChristian Biesinger <cbiesinger@google.com>2019-10-31 15:46:01 -0500
commit8d6efaa20d9b44cc016ae0f55aeceabcfe7d4e68 (patch)
treeaa5438f484f3357015e617c0fee2efa303cf390d /gdb/agent.c
parent33cb1647d68d9a57e6659a9392044ee0276fc24e (diff)
downloadgdb-8d6efaa20d9b44cc016ae0f55aeceabcfe7d4e68.zip
gdb-8d6efaa20d9b44cc016ae0f55aeceabcfe7d4e68.tar.gz
gdb-8d6efaa20d9b44cc016ae0f55aeceabcfe7d4e68.tar.bz2
Don't read agent symbols when disabled
This avoids unnecessary work, and becomes important with the patch in https://sourceware.org/ml/gdb-patches/2019-10/msg01143.html gdb/ChangeLog: 2019-10-31 Christian Biesinger <cbiesinger@google.com> * agent.c (set_can_use_agent): When the setting is turned on, look up agent symbols if we don't have them yet. (agent_new_objfile): Don't look up agent symbols when the agent setting is off. Change-Id: I6523a5640c95d38299998050a6c620e51096e8ed
Diffstat (limited to 'gdb/agent.c')
-rw-r--r--gdb/agent.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/gdb/agent.c b/gdb/agent.c
index bc71860..da251a3 100644
--- a/gdb/agent.c
+++ b/gdb/agent.c
@@ -20,6 +20,8 @@
#include "gdbcmd.h"
#include "target.h"
#include "gdbsupport/agent.h"
+#include "observable.h"
+#include "objfiles.h"
/* Enum strings for "set|show agent". */
@@ -46,20 +48,29 @@ show_can_use_agent (struct ui_file *file, int from_tty,
static void
set_can_use_agent (const char *args, int from_tty, struct cmd_list_element *c)
{
- if (target_use_agent (can_use_agent == can_use_agent_on) == 0)
+ bool can_use = (can_use_agent == can_use_agent_on);
+ if (can_use && !agent_loaded_p ())
+ {
+ /* Since the setting was off, we may not have observed the objfiles and
+ therefore not looked up the required symbols. Do so now. */
+ for (objfile *objfile : current_program_space->objfiles ())
+ if (agent_look_up_symbols (objfile) == 0)
+ break;
+ }
+ if (target_use_agent (can_use) == 0)
/* Something wrong during setting, set flag to default value. */
can_use_agent = can_use_agent_off;
}
-#include "observable.h"
-#include "objfiles.h"
-
static void
agent_new_objfile (struct objfile *objfile)
{
if (objfile == NULL || agent_loaded_p ())
return;
+ if (can_use_agent == can_use_agent_off)
+ return;
+
agent_look_up_symbols (objfile);
}