[Bug gdb/27322] New: Connecting to remote target while thread on another target is running results in bad state
simark at simark dot ca
sourceware-bugzilla@sourceware.org
Tue Feb 2 21:15:25 GMT 2021
https://sourceware.org/bugzilla/show_bug.cgi?id=27322
Bug ID: 27322
Summary: Connecting to remote target while thread on another
target is running results in bad state
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: simark at simark dot ca
Target Milestone: ---
Setup GDB with a running native inferior 1, and an inferior 2:
$ ./gdb -q -nx --data-directory=data-directory /bin/sleep -ex "set sysroot /"
-ex "set confirm off" -ex "maint set target-non-stop on" -ex "r 9999 &" -ex
"add-inferior -exec /bin/sleep -no-connection" -ex "inferior 2"
Start GDBserver:
$ gdbserver --once :1234 /bin/sleep 11111
And connect GDB to gdbserver:
(gdb) tar ext :1234
The thread from inferior 1 appears to be running:
(gdb) i th
Id Target Id Frame
1.1 process 651601 "sleep" (running)
* 2.1 Thread 651613.651613 "sleep" 0x00007ffff7fd2090 in _start ()
from /lib64/ld-linux-x86-64.so.2
But in reality it is stopped, as shown by the `t` in the ps output:
simark 651601 0.0 0.0 7864 816 pts/7 t 16:07 0:00
/usr/bin/sleep 9999
The state of the thread is changed when stop_all_threads is called, when
setting up the remote connection:
#0 stop_all_threads () at /home/simark/src/binutils-gdb/gdb/infrun.c:4567
#1 0x0000558fa5a717be in remote_target::process_initial_stop_replies
(this=0x61700003db80, from_tty=1) at
/home/simark/src/binutils-gdb/gdb/remote.c:4565
#2 0x0000558fa5a766fc in remote_target::start_remote (this=0x61700003db80,
from_tty=1, extended_p=1) at /home/simark/src/binutils-gdb/gdb/remote.c:4905
#3 0x0000558fa5a7df38 in remote_target::open_1 (name=0x60200009c1d8 ":1234",
from_tty=1, extended_p=1) at /home/simark/src/binutils-gdb/gdb/remote.c:5736
#4 0x0000558fa5a7764d in extended_remote_target::open (name=0x60200009c1d8
":1234", from_tty=1) at /home/simark/src/binutils-gdb/gdb/remote.c:4974
#5 0x0000558fa60e8a2f in open_target (args=0x60200009c1d8 ":1234", from_tty=1,
command=0x611000064040) at /home/simark/src/binutils-gdb/gdb/target.c:230
stop_all_threads stops the thread of the native target and marks it as
!tp->executing and !tp->resumed. But t->state is still THREAD_RUNNING, which
is why it appears as running in the info threads output. The debug session is
kind of screwed because GDB won't stop nor resume that thread, it is in an
in-between state.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Gdb-prs
mailing list