• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修订版6866f55720b7f4bf54b32fc2b89be08453a67b2d (tree)
时间2019-09-07 07:39:08
作者Pedro Alves <palves@redh...>
CommiterPedro Alves

Log Message

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:
yyyy-mm-dd 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.

更改概述

差异

--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -4709,8 +4709,8 @@ remote_target::start_remote (int from_tty, int extended_p)
47094709 says should be current. If we're reconnecting to a
47104710 multi-threaded program, this will ideally be the thread
47114711 that last reported an event before GDB disconnected. */
4712- inferior_ptid = get_current_thread (wait_status);
4713- if (inferior_ptid == null_ptid)
4712+ ptid_t curr_thread = get_current_thread (wait_status);
4713+ if (curr_thread == null_ptid)
47144714 {
47154715 /* Odd... The target was able to list threads, but not
47164716 tell us which thread was current (no "thread"
@@ -4722,8 +4722,14 @@ remote_target::start_remote (int from_tty, int extended_p)
47224722 "warning: couldn't determine remote "
47234723 "current thread; picking first in list.\n");
47244724
4725- inferior_ptid = inferior_list->thread_list->ptid;
4725+ for (thread_info *tp : all_non_exited_threads ())
4726+ {
4727+ switch_to_thread (tp);
4728+ break;
4729+ }
47264730 }
4731+ else
4732+ switch_to_thread (find_thread_ptid (curr_thread));
47274733 }
47284734
47294735 /* init_wait_for_inferior should be called before get_offsets in order