Don't read agent symbols when disabled
authorChristian Biesinger <cbiesinger@google.com>
Thu, 31 Oct 2019 00:10:13 +0000 (19:10 -0500)
committerChristian Biesinger <cbiesinger@google.com>
Thu, 31 Oct 2019 20:46:01 +0000 (15:46 -0500)
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

gdb/ChangeLog
gdb/agent.c

index cdc44bca63ff209fcb1653be4ce284bce77f4e75..3c26e6d6f373f0fed54f2abcd6eaacb004ed10c5 100644 (file)
@@ -1,3 +1,10 @@
+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.
+
 2019-10-31  Christian Biesinger  <cbiesinger@google.com>
 
        * config.in: Regenerate.
index bc71860864a7087f679293953d8d79e664f143db..da251a3af7b7c52b83d31709a540b9e5ddce7d85 100644 (file)
@@ -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);
 }
 
This page took 0.031574 seconds and 4 git commands to generate.