[Bug gdb/23377] [8.1 -> 8.2 regression] gdb.base/multi-forks.exp, with gdbserver

cvs-commit at gcc dot gnu.org sourceware-bugzilla@sourceware.org
Wed Jul 11 22:54:00 GMT 2018


https://sourceware.org/bugzilla/show_bug.cgi?id=23377

--- Comment #11 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The gdb-8.2-branch branch has been updated by Pedro Alves
<palves@sourceware.org>:

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

commit 1f010560368f7726eba2629a3c26298cab5d87b3
Author: Pedro Alves <palves@redhat.com>
Date:   Wed Jul 11 23:40:50 2018 +0100

    GDBserver: Don't assume a current process in D;PID implementation (PR
gdb/23377)

    This fixes a gdb.base/multi-forks.exp regression with GDBserver.

    Git commit f2ffa92bbce9 ("gdb: Eliminate the 'stop_pc' global") caused
    the regression by exposing a latent bug in gdbserver.

    The bug is that GDBserver's implementation of the D;PID packet
    incorrectly assumes that the selected thread points to the process
    being detached.  This happens via the any_persistent_commands call,
    which calls current_process:

      (gdb) bt
      #0  0x000000000040a57e in internal_error(char const*, int, char const*,
...)
      (file=0x4a53c0 "src/gdb/gdbserver/inferiors.c", line=212, fmt=0x4a539e
"%s:
      Assertion `%s' failed.") at src/gdb/gdbserver/../common/errors.c:54
      #1  0x0000000000420acf in current_process() () at
      src/gdb/gdbserver/inferiors.c:212
      #2  0x00000000004226a0 in any_persistent_commands() () at
      gdb/gdbserver/mem-break.c:308
      #3  0x000000000042cb43 in handle_detach(char*) (own_buf=0x6f0280
"D;62ea") at
      src/gdb/gdbserver/server.c:1210
      #4  0x0000000000433af3 in process_serial_event() () at
      src/gdb/gdbserver/server.c:4055
      #5  0x0000000000434878 in handle_serial_event(int, void*) (err=0,
      client_data=0x0)

    The "eliminate stop_pc" commit exposes the problem because before that
    commit, GDB's switch_to_thread always read the newly-selected thread's
    PC, and that would end up forcing GDBserver's selected thread to
    change accordingly as side effect.  After that commit, GDB no longer
    reads the thread's PC, and GDBserver does not switch the thread.

    Fix this by removing the assumption from GDBserver.

    gdb/gdbserver/ChangeLog:
    2018-07-11  Pedro Alves  <palves@redhat.com>

        PR gdb/23377
        * mem-break.c (any_persistent_commands): Add process_info
        parameter and use it instead of relying on the current process.
        Change return type to bool.
        * mem-break.h (any_persistent_commands): Add process_info
        parameter and change return type to bool.
        * server.c (handle_detach): Remove require_running_or_return call.
        Look up the process_info for the process we're about to detach.
        If not found, return back error to GDB.  Adjust
        any_persistent_commands call to pass down a process pointer.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Gdb-prs mailing list