public inbox for gdb-testers@sourceware.org help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net To: gdb-testers@sourceware.org Subject: [binutils-gdb] Avoid another inferior_ptid reference in gdb/remote.c Date: Sat, 11 Jan 2020 08:42:00 -0000 [thread overview] Message-ID: <e7af6c702da7a77529afdeffbbe6e13639beb441@gdb-build> (raw) *** TEST RESULTS FOR COMMIT e7af6c702da7a77529afdeffbbe6e13639beb441 *** commit e7af6c702da7a77529afdeffbbe6e13639beb441 Author: Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> AuthorDate: Fri Jan 10 20:05:52 2020 +0000 Commit: Pedro Alves <palves@redhat.com> CommitDate: Fri Jan 10 20:05:52 2020 +0000 Avoid another 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: 2020-01-10 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Pedro Alves <palves@redhat.com> * remote.c (remote_target::remote_parse_stop_reply) <W/X packets>: If no process is specified, return null_ptid instead of inferior_ptid. (remote_target::wait_as): Handle TARGET_WAITKIND_EXITED / TARGET_WAITKIND_SIGNALLED with no pid. gdb/testsuite/ChangeLog: 2020-01-10 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> Pedro Alves <palves@redhat.com> * gdb.server/connect-without-multi-process.exp: Also test continuing to end. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9d63febea0..7892202168 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2020-01-10 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> + Pedro Alves <palves@redhat.com> + + * remote.c (remote_target::remote_parse_stop_reply) <W/X packets>: + If no process is specified, return null_ptid instead of + inferior_ptid. + (remote_target::wait_as): Handle TARGET_WAITKIND_EXITED / + TARGET_WAITKIND_SIGNALLED with no pid. + 2020-01-10 Pedro Alves <palves@redhat.com> * remote.c (first_remote_resumed_thread): New. diff --git a/gdb/remote.c b/gdb/remote.c index fa940dff72..ffdeede7af 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -7441,7 +7441,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 @@ -7465,8 +7464,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, return null_ptid, and let the + caller figure out the right process to use. */ + int pid = 0; if (*p == '\0') ; else if (*p == ';') @@ -7842,8 +7842,16 @@ remote_target::wait_as (ptid_t ptid, target_waitstatus *status, int options) event_ptid = first_remote_resumed_thread (); } else - /* A process exit. Invalidate our notion of current thread. */ - record_currthread (rs, minus_one_ptid); + { + /* A process exit. Invalidate our notion of current thread. */ + record_currthread (rs, minus_one_ptid); + /* It's possible that the packet did not include a pid. */ + if (event_ptid == null_ptid) + event_ptid = first_remote_resumed_thread (); + /* EVENT_PTID could still be NULL_PTID. Double-check. */ + if (event_ptid == null_ptid) + event_ptid = magic_null_ptid; + } return event_ptid; } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 4b38c214da..52d52d15f6 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2020-01-10 Tankut Baris Aktemur <tankut.baris.aktemur@intel.com> + Pedro Alves <palves@redhat.com> + + * gdb.server/connect-without-multi-process.exp: Also test + continuing to end. + 2020-01-10 Pedro Alves <palves@redhat.com> * gdb.base/remote-exec-file.exp: New file. diff --git a/gdb/testsuite/gdb.server/connect-without-multi-process.exp b/gdb/testsuite/gdb.server/connect-without-multi-process.exp index 6c7d162492..123089260d 100644 --- a/gdb/testsuite/gdb.server/connect-without-multi-process.exp +++ b/gdb/testsuite/gdb.server/connect-without-multi-process.exp @@ -14,7 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. */ # Check that we can connect to GDBserver with the multiprocess -# extensions disabled, and run to main. +# extensions disabled, run to main, and finish the process. load_lib gdbserver-support.exp @@ -52,6 +52,11 @@ proc do_test {multiprocess} { "target $gdbserver_protocol" gdb_test "continue" "main .*" "continue to main" + + # 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 } foreach multiprocess { "off" "auto" } {
next reply other threads:[~2020-01-11 8:42 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-01-11 8:42 gdb-buildbot [this message] 2020-01-11 8:42 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, branch master gdb-buildbot 2020-01-13 4:05 ` Failures on Fedora-i686, " gdb-buildbot 2020-01-13 4:23 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot 2020-01-13 4:45 ` Failures on Fedora-x86_64-m64, " gdb-buildbot 2020-01-13 4:45 ` Failures on Fedora-x86_64-m32, " gdb-buildbot 2020-01-13 5:36 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot 2020-01-13 5:46 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot 2020-01-13 5:48 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot 2020-01-13 5:48 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot
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=e7af6c702da7a77529afdeffbbe6e13639beb441@gdb-build \ --to=gdb-buildbot@sergiodj.net \ --cc=gdb-testers@sourceware.org \ /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: linkBe 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; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).