along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
-
-/* Local non-gdb includes. */
#include "command.h"
-#include "common/agent.h"
#include "gdbcmd.h"
#include "target.h"
+#include "gdbsupport/agent.h"
+#include "observable.h"
+#include "objfiles.h"
/* Enum strings for "set|show agent". */
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);
}