Bug 19064 - Running shared in continue post-hook causes gdb remote command/response mismatch
Summary: Running shared in continue post-hook causes gdb remote command/response mismatch
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: remote (show other bugs)
Version: HEAD
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-10-05 12:18 UTC by Charles McLachlan
Modified: 2015-10-05 12:18 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Charles McLachlan 2015-10-05 12:18:21 UTC
I am seeing a problem with putting 'shared' in a continue post hook when debugging a remote target with gdb from git (e753e154bf8a1f507b43e03dec04b341dde3f429 cloned from git://sourceware.org/git/binutils-gdb.git around 12:00 BST 5th October 2015).

It looks like gdb is not waiting for the response to continue before running shared. This causes an $qXfer:libraries-svr4:read::0,fff#91 serial packet to be sent before the response to the $vCont;c#a8 is recieved.

Here is a simple reproducer script

gdb_git_install/bin/gdbserver  localhost:6790 /bin/ls nowhere  &
cat <<EOF | gdb_git_install/bin/gdb
set debug remote 1
maintenance set target-async off
define hookpost-continue
shared
end
target remote localhost:6790
continue
EOF

The important bit of the log is (on my machine)

(gdb) Continuing.
Sending packet: $QPassSignals:e;10;14;17;1a;1b;1c;21;24;25;2c;4c;#5f...Packet received: OK
Sending packet: $vCont?#49...Packet received: vCont;c;C;s;S;t;r
Packet vCont (verbose-resume) is supported
Sending packet: $vCont;c#a8...Sending packet: $qXfer:libraries-svr4:read::0,fff#91...
...
Unknown remote qXfer reply: T05swbreak:;06:f0d1ffffff7f0000;07:08d1ffffff7f0000;10:a0a9def7ff7f0000;thread:p34be.34be;core:3;

Showing the two packets ($vCont and $qXfer) being sent out without a 'Packet received' in between, meaning that qXfer ends up with the response that should have gone to vCont 

After that, any command I try (apart from interrupt) returns "Target is executing." and interrupt causes a hang.

Correct behaviour is recovered if target-async is not switched off, by ommitting the line 'maintenance set target-async off'

This (pretty much as expected) gives the error message

Cannot execute this command while the target is running.
Use the "interrupt" command to stop the target
and then try again.

The commit that seems to have caused the issue is 0b333c5e7d6c3fc65d37ffa11bd21ba52c4adb25 (https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=0b333c5e7d6c3fc65d37ffa11bd21ba52c4adb25) 'Merge async and sync code paths some more' by Pedro Alves