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] Fix reconnecting to a gdbserver already debugging multiple processes, II Date: Sat, 11 Jan 2020 10:20:00 -0000 [thread overview] Message-ID: <75c6c844d9df37761e0e834df057b89e41816e55@gdb-build> (raw) *** TEST RESULTS FOR COMMIT 75c6c844d9df37761e0e834df057b89e41816e55 *** commit 75c6c844d9df37761e0e834df057b89e41816e55 Author: Pedro Alves <palves@redhat.com> AuthorDate: Fri Jan 10 20:05:54 2020 +0000 Commit: Pedro Alves <palves@redhat.com> CommitDate: Fri Jan 10 20:05:54 2020 +0000 Fix reconnecting to a gdbserver already debugging multiple processes, II Another bug exposed by gdb.server/extended-remote-restart.exp in the multi-target work is that remote_target::start_remote can leave inferior_ptid and current_inferior() out of sync: (top-gdb) p current_inferior_->pid $1 = 29541 (top-gdb) p inferior_ptid $2 = {m_pid = 29540, m_lwp = 29540, m_tid = 0} This is caused by writing to inferior_ptid directly instead of using switch_to_thread. Also, "inferior_list->thread_list->ptid" assumes that we want the first thread of the first inferior, but that inferior may not have threads, or with multi-target, that target may be connected to some other target. gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * remote.c (remote_target::start_remote): Don't set inferior_ptid directly. Instead find the first thread in the thread list and use switch_to_thread. diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 4163c869af..a6fd8b11cd 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2020-01-10 Pedro Alves <palves@redhat.com> + + * remote.c (remote_target::start_remote): Don't set inferior_ptid + directly. Instead find the first thread in the thread list and + use switch_to_thread. + 2020-01-10 Pedro Alves <palves@redhat.com> * remote.c (remote_target::remote_add_inferior): Don't bind a diff --git a/gdb/remote.c b/gdb/remote.c index 751769ea7f..f017f4a719 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -4701,8 +4701,8 @@ remote_target::start_remote (int from_tty, int extended_p) says should be current. If we're reconnecting to a multi-threaded program, this will ideally be the thread that last reported an event before GDB disconnected. */ - inferior_ptid = get_current_thread (wait_status); - if (inferior_ptid == null_ptid) + ptid_t curr_thread = get_current_thread (wait_status); + if (curr_thread == null_ptid) { /* Odd... The target was able to list threads, but not tell us which thread was current (no "thread" @@ -4714,8 +4714,14 @@ remote_target::start_remote (int from_tty, int extended_p) "warning: couldn't determine remote " "current thread; picking first in list.\n"); - inferior_ptid = inferior_list->thread_list->ptid; + for (thread_info *tp : all_non_exited_threads ()) + { + switch_to_thread (tp); + break; + } } + else + switch_to_thread (find_thread_ptid (curr_thread)); } /* init_wait_for_inferior should be called before get_offsets in order
next reply other threads:[~2020-01-11 10:20 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-01-11 10:20 gdb-buildbot [this message] 2020-01-11 10:20 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, branch master gdb-buildbot 2020-01-11 10:36 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot 2020-01-13 10:10 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot 2020-01-13 10:29 ` Failures on Fedora-x86_64-m32, " gdb-buildbot 2020-01-13 10:44 ` Failures on Fedora-x86_64-m64, " gdb-buildbot 2020-01-13 11:29 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot 2020-01-13 11:29 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot 2020-01-13 12:31 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot 2020-01-13 13:11 ` 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=75c6c844d9df37761e0e834df057b89e41816e55@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).