From patchwork Thu Oct 31 20:47:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 35537 Received: (qmail 71080 invoked by alias); 31 Oct 2019 20:47:12 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 71065 invoked by uid 89); 31 Oct 2019 20:47:12 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 31 Oct 2019 20:47:10 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 181132031F; Thu, 31 Oct 2019 16:47:08 -0400 (EDT) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id B70592031F; Thu, 31 Oct 2019 16:47:07 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 98220218A2; Thu, 31 Oct 2019 16:47:07 -0400 (EDT) X-Gerrit-PatchSet: 2 Date: Thu, 31 Oct 2019 16:47:07 -0400 From: "Sourceware to Gerrit sync (Code Review)" To: Christian Biesinger , gdb-patches@sourceware.org Cc: Tom Tromey Auto-Submitted: auto-generated X-Gerrit-MessageType: merged Subject: [pushed] Don't read agent symbols when disabled X-Gerrit-Change-Id: I6523a5640c95d38299998050a6c620e51096e8ed X-Gerrit-Change-Number: 464 X-Gerrit-ChangeURL: X-Gerrit-Commit: 8d6efaa20d9b44cc016ae0f55aeceabcfe7d4e68 In-Reply-To: References: Reply-To: noreply@gnutoolchain-gerrit.osci.io, tromey@sourceware.org, cbiesinger@google.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-75-g9005159e5d Message-Id: <20191031204707.98220218A2@gnutoolchain-gerrit.osci.io> Sourceware to Gerrit sync has submitted this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/464 ...................................................................... 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 * 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 --- M gdb/ChangeLog M gdb/agent.c 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index cdc44bc..3c26e6d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2019-10-31 Christian Biesinger + * 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 + * config.in: Regenerate. 2019-10-31 Christian Biesinger 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 @@ 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); }