From patchwork Thu Oct 31 01:47:58 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: 35508 Received: (qmail 129898 invoked by alias); 31 Oct 2019 01:48:09 -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 129829 invoked by uid 89); 31 Oct 2019 01:48:03 -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 01:48:02 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id 815D520250; Wed, 30 Oct 2019 21:48:00 -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 D961E20250; Wed, 30 Oct 2019 21:47:58 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id B055720AF6; Wed, 30 Oct 2019 21:47:58 -0400 (EDT) X-Gerrit-PatchSet: 1 Date: Wed, 30 Oct 2019 21:47:58 -0400 From: "Christian Biesinger (Code Review)" To: gdb-patches@sourceware.org Cc: Christian Biesinger Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Don't read agent symbols when disabled X-Gerrit-Change-Id: I6523a5640c95d38299998050a6c620e51096e8ed X-Gerrit-Change-Number: 464 X-Gerrit-ChangeURL: X-Gerrit-Commit: df8f515098f76822e1f0dcd4ccd9f8f7bec203bc References: Reply-To: cbiesinger@google.com, cbiesinger@google.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-75-g9005159e5d 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-30 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/agent.c 1 file 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 @@ 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); }