From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from barracuda.ebox.ca (barracuda.ebox.ca [96.127.255.19]) by sourceware.org (Postfix) with ESMTPS id 94C1A3858405 for ; Sat, 30 Apr 2022 03:21:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 94C1A3858405 X-ASG-Debug-ID: 1651288877-0c856e06abd37590001-fS2M51 Received: from smtp.ebox.ca (smtp.ebox.ca [96.127.255.82]) by barracuda.ebox.ca with ESMTP id dWHvrrSuCzQ25ykF (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 29 Apr 2022 23:21:17 -0400 (EDT) X-Barracuda-Envelope-From: simon.marchi@polymtl.ca X-Barracuda-RBL-Trusted-Forwarder: 96.127.255.82 Received: from simark.localdomain (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) by smtp.ebox.ca (Postfix) with ESMTP id 09762441D65; Fri, 29 Apr 2022 23:21:17 -0400 (EDT) From: Simon Marchi X-Barracuda-RBL-IP: 192.222.157.6 X-Barracuda-Effective-Source-IP: 192-222-157-6.qc.cable.ebox.net[192.222.157.6] X-Barracuda-Apparent-Source-IP: 192.222.157.6 To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH v2 2/2] gdb/remote: send qSymbol to all inferiors on startup Date: Fri, 29 Apr 2022 23:21:15 -0400 X-ASG-Orig-Subj: [PATCH v2 2/2] gdb/remote: send qSymbol to all inferiors on startup Message-Id: <20220430032115.524232-3-simon.marchi@polymtl.ca> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220430032115.524232-1-simon.marchi@polymtl.ca> References: <20220430032115.524232-1-simon.marchi@polymtl.ca> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Barracuda-Connect: smtp.ebox.ca[96.127.255.82] X-Barracuda-Start-Time: 1651288877 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://96.127.255.19:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at ebox.ca X-Barracuda-Scan-Msg-Size: 3919 X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.50 X-Barracuda-Spam-Status: No, SCORE=0.50 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=8.0 tests=BSF_RULE7568M X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.97692 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.50 BSF_RULE7568M Custom Rule 7568M X-Spam-Status: No, score=-3612.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_QUARANTINE, KAM_DMARC_STATUS, KAM_LOTSOFHASH, KAM_STOCKGEN, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_SOFTFAIL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Apr 2022 03:21:24 -0000 From: Simon Marchi start_remote_1 calls remote_check_symbols after things are set up to give the remote side a chance to look up symbols. One call to remote_check_symbols sets the "general thread", if needed, and sends one qSymbol packet. In theory, a remote target could have more than one process on initial connection, and this would send a qSymbol for only one of these processes. Change it to iterate on all the target's inferiors and send a qSymbol packet for each one. I was able to kind of test this by changing gdbserver to spawn two processes on startup: diff --git a/gdbserver/server.cc b/gdbserver/server.cc index 33c42714e72..9b682e9f85f 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -3939,6 +3939,7 @@ captured_main (int argc, char *argv[]) /* Wait till we are at first instruction in program. */ target_create_inferior (program_path.get (), program_args); + target_create_inferior (program_path.get (), program_args); /* We are now (hopefully) stopped at the first instruction of the target process. This assumes that the target process was And I was able to see qSymbol being sent for each inferior: [remote] Sending packet: $Hgp828dc.828dc#1f [remote] Packet received: OK [remote] Sending packet: $qSymbol::#5b [remote] Packet received: qSymbol:6764625f6167656e745f6764625f74705f686561705f627566666572 [remote] Sending packet: $qSymbol::6764625f6167656e745f6764625f74705f686561705f627566666572#1e [remote] Packet received: qSymbol:6e70746c5f76657273696f6e [remote] Sending packet: $qSymbol::6e70746c5f76657273696f6e#4d [remote] Packet received: OK [remote] Sending packet: $Hgp828dd.828dd#21 [remote] Packet received: OK [remote] Sending packet: $qSymbol::#5b [remote] Packet received: qSymbol:6764625f6167656e745f6764625f74705f686561705f627566666572 [remote] Sending packet: $qSymbol::6764625f6167656e745f6764625f74705f686561705f627566666572#1e [remote] Packet received: qSymbol:6e70746c5f76657273696f6e [remote] Sending packet: $qSymbol::6e70746c5f76657273696f6e#4d [remote] Packet received: OK Note that there would probably be more work to be done to fully support this scenario, more things that need to be done for each discovered inferior instead of just for one. Change-Id: I21c4ecf6367391e2e389b560f0b4bd906cf6472f --- gdb/remote.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/gdb/remote.c b/gdb/remote.c index fde6df3f84d5..b82140dc3d09 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -5021,12 +5021,24 @@ remote_target::start_remote_1 (int from_tty, int extended_p) target_async (1); } - /* If we connected to a live target, do some additional setup. */ - if (target_has_execution ()) + /* Give the target a chance to look up symbols. */ + for (inferior *inf : all_inferiors (this)) { + /* The inferiors that exist at this point were created from what + was found already running on the remote side, so we know they + have execution. */ + gdb_assert (this->has_execution (inf)); + /* No use without a symbol-file. */ - if (current_program_space->symfile_object_file) - remote_check_symbols (); + if (inf->pspace->symfile_object_file == nullptr) + continue; + + /* Need to switch to a specific thread, because remote_check_symbols + uses INFERIOR_PTID to set the general thread. */ + scoped_restore_current_thread restore_thread; + thread_info *thread = any_thread_of_inferior (inf); + switch_to_thread (thread); + this->remote_check_symbols (); } /* Possibly the target has been engaged in a trace run started -- 2.36.0