Bug 23382 - gdb.base/interrupt-daemon.exp fails with --target_board=native-gdbserver
Summary: gdb.base/interrupt-daemon.exp fails with --target_board=native-gdbserver
Status: NEW
Alias: None
Product: gdb
Classification: Unclassified
Component: server (show other bugs)
Version: unknown
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 18945 (view as bug list)
Depends on:
Blocks:
 
Reported: 2018-07-06 15:21 UTC by Pedro Alves
Modified: 2022-11-27 16:59 UTC (History)
2 users (show)

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 Pedro Alves 2018-07-06 15:21:37 UTC
Testing on F27 with --target_board=native-gdbserver I get:

+FAIL: gdb.base/interrupt-daemon.exp: fg: ctrl-c stops process (timeout) 
+FAIL: gdb.base/interrupt-daemon.exp: bg: continue& (timeout) 
+FAIL: gdb.base/interrupt-daemon.exp: bg: interrupt (timeout) 
+FAIL: gdb.base/interrupt-daemon.exp: bg: interrupt cmd stops process (timeout)
Comment 1 Sergio Durigan Junior 2018-07-07 17:58:22 UTC
Confirming that this also happens with --target_board=native-extended-gdbserver.
Comment 2 Sergio Durigan Junior 2018-07-07 20:28:31 UTC
The test was added by:

commit e671cd59d74cec9f53e110ce887128d1eeadb7f2 (HEAD)
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Jan 30 14:23:51 2018 +0000

Interestingly, I cannot make it pass even using this commit as HEAD.  Examining the BuildBot logs, I see that the test only passed on native, and never on --target_board=native-{extended-}gdbserver.
Comment 3 Sourceware Commits 2022-11-27 09:31:56 UTC
The master branch has been updated by Tom de Vries <vries@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4c35c4c6a779c79e456b7a5311f74aafc9026bd5

commit 4c35c4c6a779c79e456b7a5311f74aafc9026bd5
Author: Tom de Vries <tdevries@suse.de>
Date:   Sun Nov 27 10:31:50 2022 +0100

    [gdb/server] Emit warning for SIGINT failure
    
    Consider the executable from test-case gdb.base/interrupt-daemon.exp.
    
    When starting it using gdbserver:
    ...
    $ ./build/gdbserver/gdbserver localhost:2345 \
      ./outputs/gdb.base/interrupt-daemon/interrupt-daemon
    ...
    and connecting to it using gdb:
    ...
    $ gdb -q -ex "target remote localhost:2345" \
        -ex "set follow-fork-mode child" \
        -ex "break daemon_main" -ex cont
    ...
    we are setup to do the same as in the test-case: interrupt a running inferior
    using ^C.
    
    So let's try:
    ...
    (gdb) continue
    Continuing.
    ^C
    ...
    After pressing ^C, nothing happens.  This a known problem, filed as
    PR remote/18772.
    
    The problem is that in linux_process_target::request_interrupt, a kill is used
    to send a SIGINT, but it fails.  And it fails silently.
    
    Make the failure verbose by adding a warning, such that the gdbserver output
    becomes more helpful:
    ...
    Process interrupt-daemon created; pid = 15068
    Listening on port 2345
    Remote debugging from host ::1, port 35148
    Detaching from process 15068
    Detaching from process 15085
    gdbserver: Sending SIGINT to process group of pid 15068 failed: \
      No such process
    ...
    
    Note that the failure can easily be reproduced using the test-case and target
    board native-gdbserver:
    ...
    (gdb) continue^M
    Continuing.^M
    PASS: gdb.base/interrupt-daemon.exp: fg: continue
    ^CFAIL: gdb.base/interrupt-daemon.exp: fg: ctrl-c stops process (timeout)
    ...
    as reported in PR server/23382.
    
    Tested on x86_64-linux.
    Approved-By: Simon Marchi <simon.marchi@efficios.com>
Comment 4 Tom de Vries 2022-11-27 16:59:31 UTC
*** Bug 18945 has been marked as a duplicate of this bug. ***