From: Pedro Alves <palves@redhat.com>
To: Philippe Waroquiers <philippe.waroquiers@skynet.be>,
gdb-patches@sourceware.org
Subject: [PATCH] Avoid inferior_ptid reference in gdb/remote.c (Re: [PATCH 00/23] Multi-target support)
Date: Wed, 16 Oct 2019 19:14:00 -0000 [thread overview]
Message-ID: <9f323dab-8f2a-50e3-1de6-647910b31a78@redhat.com> (raw)
In-Reply-To: <6c1828abbbfda76da123926fda8b37816132075a.camel@skynet.be>
Pedro Alves wrote:
On 9/8/19 9:50 PM, Philippe Waroquiers wrote:
>> Then when stopping this gdb (which automatically continues the valgrind executables
>> till valgrind reports the next error), launching a new gdb, and only connecting to the 32
>> bits valgrind gdbserver, here is what I see.
>>
>> (gdb) tar rem|lvgdb --pid=16727
>> Remote debugging using |lvgdb
>> ...
>> 0x04001092 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
>> (gdb) bt
>> #0 0x04001092 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
>> #1 0x0495fd27 in syscall () at ../sysdeps/unix/sysv/linux/i386/syscall.S:29
>> #2 0x0010922c in main () at scalar_exit_group.c:14
>> (gdb) c
>> Continuing.
>> ../../multi-target-v1/gdb/inferior.c:285: internal-error: inferior*
>> find_inferior_pid(process_stratum_target*, int): Assertion `pid != 0' failed.
>> A problem internal to GDB has been detected,
>> further debugging may prove unreliable.
>> Quit this debugging session? (y or n)
>>
>> So, that looks to be a regression with the valgrind gdbserver.
> Thanks. I'll have to try reproducing this.
Thanks for spotting this. It was a regression against any remote target
that does not support the remote protocol multi-process extensions.
This patch fixes it.
From cd7e386563fcdb43d647ce499c5e05b85d44ba68 Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Tue, 15 Oct 2019 20:01:55 +0100
Subject: [PATCH] Avoid inferior_ptid reference in gdb/remote.c
The multi-target patch makes inferior_ptid point to null_ptid before
calling into target_wait, which catches bad uses of inferior_ptid,
since the current selected thread in gdb shouldn't have much relation
to the thread that reports an event.
One such bad use is found in remote_target::remote_parse_stop_reply,
where we handle the 'W' or 'X' packets (process exit), and the remote
target does not support the multi-process extensions, i.e., it does
not report the PID of the process that exited.
With the multi-target patch, that would result in a failed assertion,
trying to find the inferior for process pid 0.
gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* remote.c (remote_target::remote_parse_stop_reply) <W/X packets>:
If no process is specified, assume remote's current process
instead of inferior_ptid.
gdb/testsuite/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* gdb.server/no-multi-process.exp: New file.
---
gdb/remote.c | 6 ++--
gdb/testsuite/gdb.server/no-multi-process.exp | 40 +++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 3 deletions(-)
create mode 100644 gdb/testsuite/gdb.server/no-multi-process.exp
diff --git a/gdb/remote.c b/gdb/remote.c
index b6d7bb0a6d..05c8b336f2 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -7511,7 +7511,6 @@ Packet: '%s'\n"),
case 'W': /* Target exited. */
case 'X':
{
- int pid;
ULONGEST value;
/* GDB used to accept only 2 hex chars here. Stubs should
@@ -7535,8 +7534,9 @@ Packet: '%s'\n"),
event->ws.value.sig = GDB_SIGNAL_UNKNOWN;
}
- /* If no process is specified, assume inferior_ptid. */
- pid = inferior_ptid.pid ();
+ /* If no process is specified, assume the remote's current
+ process. */
+ int pid = get_remote_state ()->general_thread.pid ();
if (*p == '\0')
;
else if (*p == ';')
diff --git a/gdb/testsuite/gdb.server/no-multi-process.exp b/gdb/testsuite/gdb.server/no-multi-process.exp
new file mode 100644
index 0000000000..0e946dba6f
--- /dev/null
+++ b/gdb/testsuite/gdb.server/no-multi-process.exp
@@ -0,0 +1,40 @@
+# Copyright (C) 2019 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Smoke tests for debugging against a remote target with no
+# multi-process extensions support.
+
+load_lib gdbserver-support.exp
+
+if {[skip_gdbserver_tests]} {
+ return
+}
+
+standard_testfile server.c
+if [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] {
+ return -1
+}
+
+# Make sure we're disconnected, in case we're testing with an
+# extended-remote board, therefore already connected.
+gdb_test "disconnect" ".*"
+
+gdb_test_no_output "set remote multiprocess-feature-packet off"
+gdbserver_run ""
+
+# The W/X packets do not include the PID of the exiting process
+# without the multi-process extensions. Check that we handle process
+# exit correctly in that case.
+gdb_continue_to_end "" continue 1
--
2.14.5
next prev parent reply other threads:[~2019-10-16 19:14 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-06 23:28 [PATCH 00/23] Multi-target support Pedro Alves
2019-09-06 23:28 ` [PATCH 08/23] Introduce switch_to_inferior_no_thread Pedro Alves
2019-09-09 18:42 ` Tom Tromey
2019-10-17 1:07 ` Pedro Alves
2019-09-06 23:28 ` [PATCH 11/23] tfile_target::close: trace_fd can't be -1 Pedro Alves
2019-09-06 23:28 ` [PATCH 18/23] Add multi-target tests Pedro Alves
2019-10-09 16:01 ` Aktemur, Tankut Baris
2019-10-17 0:55 ` Pedro Alves
2019-09-06 23:28 ` [PATCH 17/23] Multi-target support Pedro Alves
2019-09-11 17:11 ` Tom Tromey
2019-10-17 1:54 ` Pedro Alves
2019-09-06 23:28 ` [PATCH 06/23] Don't check target is running in remote_target::mourn_inferior Pedro Alves
2019-09-06 23:28 ` [PATCH 16/23] Fix reconnecting to a gdbserver already debugging multiple processes, II Pedro Alves
2019-09-06 23:28 ` [PATCH 03/23] Make "show remote exec-file" inferior-aware Pedro Alves
2019-09-06 23:28 ` [PATCH 19/23] gdbarch-selftests.c: No longer error out if debugging something Pedro Alves
2019-09-06 23:28 ` [PATCH 20/23] Revert 'Remove unused struct serial::name field' Pedro Alves
2019-09-06 23:47 ` Christian Biesinger via gdb-patches
2019-09-08 19:30 ` Pedro Alves
2019-09-06 23:28 ` [PATCH 09/23] switch inferior/thread before calling target methods Pedro Alves
2019-09-06 23:28 ` [PATCH 15/23] Fix reconnecting to a gdbserver already debugging multiple processes, I Pedro Alves
2019-09-06 23:28 ` [PATCH 10/23] Some get_last_target_status tweaks Pedro Alves
2019-09-09 18:53 ` Tom Tromey
2019-10-17 1:14 ` Pedro Alves
2019-09-06 23:28 ` [PATCH 01/23] Preserve selected thread in all-stop w/ background execution Pedro Alves
2019-10-09 9:36 ` Aktemur, Tankut Baris
2019-10-16 23:54 ` [PATCH v1.1 " Pedro Alves
2019-10-17 10:21 ` Aktemur, Tankut Baris
2019-09-06 23:28 ` [PATCH 02/23] Don't rely on inferior_ptid in record_full_wait Pedro Alves
2020-07-31 3:17 ` Tom Tromey
2020-08-01 16:14 ` Simon Marchi
2020-08-01 19:32 ` John Baldwin
2020-08-01 20:47 ` Tom Tromey
2020-08-01 20:46 ` Tom Tromey
2020-08-01 22:56 ` Simon Marchi
2020-08-02 17:52 ` Tom Tromey
2020-08-03 0:08 ` Simon Marchi
2019-09-06 23:28 ` [PATCH 13/23] Delete exit_inferior_silent(int pid) Pedro Alves
2019-09-06 23:33 ` [PATCH 23/23] Multi-target: NEWS and user manual Pedro Alves
2019-09-07 6:33 ` Eli Zaretskii
2019-10-17 2:08 ` Pedro Alves
2019-10-17 7:55 ` Eli Zaretskii
2019-10-17 2:42 ` Pedro Alves
2019-10-17 8:14 ` Eli Zaretskii
2019-10-17 15:31 ` Pedro Alves
2019-09-06 23:34 ` [PATCH 04/23] exceptions.c:print_flush: Remove obsolete check Pedro Alves
2019-09-09 18:07 ` Tom Tromey
2019-09-06 23:35 ` [PATCH 05/23] Make target_ops::has_execution take an 'inferior *' instead of a ptid_t Pedro Alves
2019-09-09 18:12 ` Tom Tromey
2019-09-06 23:36 ` [PATCH 07/23] Delete unnecessary code from kill_command Pedro Alves
2019-10-01 10:19 ` Aktemur, Tankut Baris
2019-10-01 13:28 ` Aktemur, Tankut Baris
2019-09-06 23:36 ` [PATCH 12/23] Use all_non_exited_inferiors in infrun.c Pedro Alves
2019-09-06 23:36 ` [PATCH 14/23] Tweak handling of remote errors in response to resumption packet Pedro Alves
2019-10-09 13:35 ` Aktemur, Tankut Baris
2019-10-17 0:54 ` [PATCH 14.5/23] Avoid another inferior_ptid reference in gdb/remote.c (Re: [PATCH 14/23] Tweak handling of remote errors in response to resumption packet) Pedro Alves
2019-09-06 23:37 ` [PATCH 21/23] Add "info connections" command, "info inferiors" connection number/string Pedro Alves
2019-09-09 20:18 ` Tom Tromey
2019-10-17 2:21 ` Pedro Alves
2019-10-17 14:23 ` Tom Tromey
2019-09-06 23:37 ` [PATCH 22/23] Require always-non-stop for multi-target resumptions Pedro Alves
2019-09-07 11:19 ` [PATCH 00/23] Multi-target support Philippe Waroquiers
2019-09-08 20:06 ` Pedro Alves
2019-09-08 20:50 ` Philippe Waroquiers
2019-10-16 19:08 ` Pedro Alves
2019-10-16 19:14 ` Pedro Alves [this message]
2019-09-09 19:09 ` Tom Tromey
2019-09-09 20:22 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9f323dab-8f2a-50e3-1de6-647910b31a78@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=philippe.waroquiers@skynet.be \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox